mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-06 19:50:40 +00:00
fix the weather command
This commit is contained in:
parent
17477c2155
commit
e3acaf8555
1 changed files with 12 additions and 13 deletions
|
|
@ -1,28 +1,27 @@
|
||||||
|
const UserError = require('flying-squid').UserError;
|
||||||
|
|
||||||
module.exports.player = function(player, serv) { // Player is a type of entity (entity inject is called first) with added properties and functions
|
module.exports.player = function(player, serv) {
|
||||||
player.commands.add({
|
player.commands.add({
|
||||||
base: 'weather',
|
base: 'weather',
|
||||||
info: 'Sets ths weather.',
|
info: 'Sets the weather.',
|
||||||
usage: '/weather <clear|rain|thunder> [duration]',
|
usage: '/weather <clear|rain>',
|
||||||
op: true,
|
op: true,
|
||||||
parse(str) {
|
parse(str) {
|
||||||
const args = str.split(' ');
|
const args = str.split(' ');
|
||||||
if(args.length!=2)
|
if(args.length!=1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let condition = player.selectorString(args[0]);
|
let condition = args[0];
|
||||||
if(condition.length==0) throw new UserError("one condition");
|
if(["clear","rain"].indexOf(condition)==-1)
|
||||||
|
return false;
|
||||||
|
|
||||||
let duration = player.selectorString(args[1]);
|
return {condition:condition};
|
||||||
if(duration.length < 1) throw new UserError("one duration");
|
|
||||||
|
|
||||||
return {condition:condition[0],duration:duration[0]};
|
|
||||||
},
|
},
|
||||||
action({condition,duration}){
|
action({condition}){
|
||||||
if(condition == 'rain'){
|
if(condition == 'rain'){
|
||||||
serv._writeAll('game_state_change',{reason:2,value:0});
|
serv._writeAll('game_state_change',{reason:2,gameMode:0});
|
||||||
} else if(condition == 'clear') {
|
} else if(condition == 'clear') {
|
||||||
serv._writeAll('game_state_change',{reason:1,value:0});
|
serv._writeAll('game_state_change',{reason:1,gameMode:0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue