mirror of
https://github.com/danbulant/flying-squid
synced 2026-09-18 05:34:14 +00:00
Merge pull request #239 from OverloadedWolf/master
[WIP] Weather Command
This commit is contained in:
commit
17477c2155
1 changed files with 29 additions and 0 deletions
29
src/lib/plugins/weather.js
Normal file
29
src/lib/plugins/weather.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
module.exports.player = function(player, serv) { // Player is a type of entity (entity inject is called first) with added properties and functions
|
||||
player.commands.add({
|
||||
base: 'weather',
|
||||
info: 'Sets ths weather.',
|
||||
usage: '/weather <clear|rain|thunder> [duration]',
|
||||
op: true,
|
||||
parse(str) {
|
||||
const args = str.split(' ');
|
||||
if(args.length!=2)
|
||||
return false;
|
||||
|
||||
let condition = player.selectorString(args[0]);
|
||||
if(condition.length==0) throw new UserError("one condition");
|
||||
|
||||
let duration = player.selectorString(args[1]);
|
||||
if(duration.length < 1) throw new UserError("one duration");
|
||||
|
||||
return {condition:condition[0],duration:duration[0]};
|
||||
},
|
||||
action({condition,duration}){
|
||||
if(condition == 'rain'){
|
||||
serv._writeAll('game_state_change',{reason:2,value:0});
|
||||
} else if(condition == 'clear') {
|
||||
serv._writeAll('game_state_change',{reason:1,value:0});
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
Loading…
Reference in a new issue