From e3acaf8555ee5c5094b8553f07d6e55cfbadfd38 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 30 Apr 2016 01:25:57 +0200 Subject: [PATCH] fix the weather command --- src/lib/plugins/weather.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/lib/plugins/weather.js b/src/lib/plugins/weather.js index 8d5ccfb..bbf6316 100644 --- a/src/lib/plugins/weather.js +++ b/src/lib/plugins/weather.js @@ -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({ base: 'weather', - info: 'Sets ths weather.', - usage: '/weather [duration]', + info: 'Sets the weather.', + usage: '/weather ', op: true, parse(str) { const args = str.split(' '); - if(args.length!=2) + if(args.length!=1) return false; - let condition = player.selectorString(args[0]); - if(condition.length==0) throw new UserError("one condition"); + let condition = args[0]; + if(["clear","rain"].indexOf(condition)==-1) + return false; - let duration = player.selectorString(args[1]); - if(duration.length < 1) throw new UserError("one duration"); - - return {condition:condition[0],duration:duration[0]}; + return {condition:condition}; }, - action({condition,duration}){ + action({condition}){ 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') { - serv._writeAll('game_state_change',{reason:1,value:0}); + serv._writeAll('game_state_change',{reason:1,gameMode:0}); } } })