From 34bb3c9713abe96103414191c53149264d9f364b Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 5 May 2020 15:41:29 +0800 Subject: [PATCH] =?UTF-8?q?setCurtain=20&=20setWeather=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E5=88=B0=E4=B8=8B=E4=B8=AA=E6=9C=AC=E4=BA=8B=E4=BB=B6=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 23 ++++++++++++----------- libs/events.js | 10 +++------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 864ccf28..658d50ba 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1525,19 +1525,20 @@ return code; */; setCurtain_0_s - : '更改画面色调' EvalString Colour '动画时间' Int? '不等待执行完毕' Bool Newline + : '更改画面色调' EvalString Colour '动画时间' Int? '持续到下一个本事件' Bool '不等待执行完毕' Bool Newline /* setCurtain_0_s tooltip : setCurtain: 更改画面色调,动画时间可不填 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setcurtain%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%94%BB%E9%9D%A2%E8%89%B2%E8%B0%83 -default : ["255,255,255,1",'rgba(255,255,255,1)',500,false] +default : ["255,255,255,1",'rgba(255,255,255,1)',500,true,false] colour : this.soundColor var colorRe = MotaActionFunctions.pattern.colorRe; if (!colorRe.test(EvalString_0))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); Int_0 = Int_0!=='' ?(', "time": '+Int_0):''; -var async = Bool_0?', "async": true':''; -var code = '{"type": "setCurtain", "color": ['+EvalString_0+']'+Int_0 +async+'},\n'; +Bool_0 = Bool_0 ? ', "keep": true' : ''; +var async = Bool_1?', "async": true':''; +var code = '{"type": "setCurtain", "color": ['+EvalString_0+']'+Int_0 +Bool_0+async+'},\n'; return code; */; @@ -1573,16 +1574,17 @@ return code; */; setWeather_s - : '更改天气' Weather_List '强度' Int Newline + : '更改天气' Weather_List '强度' Int '持续到下个本事件' Bool Newline /* setWeather_s tooltip : setWeather:更改天气 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setweather%EF%BC%9A%E6%9B%B4%E6%94%B9%E5%A4%A9%E6%B0%94 -default : [null,1] +default : [null,1,true] colour : this.soundColor if(Int_0<1 || Int_0>10) throw new Error('天气的强度等级, 在1-10之间'); -var code = '{"type": "setWeather", "name": "'+Weather_List_0+'", "level": '+Int_0+'},\n'; +Bool_0 = Bool_0 ? ', "keep": true' : '' +var code = '{"type": "setWeather", "name": "'+Weather_List_0+'", "level": '+Int_0+Bool_0+'},\n'; if(Weather_List_0===''||Weather_List_0==='null'||Weather_List_0==null)code = '{"type": "setWeather"},\n'; return code; */; @@ -3335,12 +3337,11 @@ ActionParser.prototype.parseAction = function() { this.next]); } break; - case "setFg": // 颜色渐变 - case "setCurtain": + case "setCurtain": // 颜色渐变 if(this.isset(data.color)){ data.color = this.Colour(data.color); this.next = MotaActionBlocks['setCurtain_0_s'].xmlText([ - data.color,'rgba('+data.color+')',data.time||0,data.async||false,this.next]); + data.color,'rgba('+data.color+')',data.time||0,data.keep||false,data.async||false,this.next]); } else { this.next = MotaActionBlocks['setCurtain_1_s'].xmlText([ data.time||0,data.async||false,this.next]); @@ -3353,7 +3354,7 @@ ActionParser.prototype.parseAction = function() { break; case "setWeather": // 更改天气 this.next = MotaActionBlocks['setWeather_s'].xmlText([ - data.name,data.level||1,this.next]); + data.name,data.level||1,data.keep||false,this.next]); break; case "openDoor": // 开一个门, 包括暗墙 data.loc=data.loc||['',''] diff --git a/libs/events.js b/libs/events.js index 1c498f88..de33cc90 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1434,19 +1434,15 @@ events.prototype._precompile_moveImage = function (data) { return data; } -events.prototype._action_setFg = function (data, x, y, prefix) { - return this._action_setCurtain(data, x, y, prefix); -} - events.prototype._action_setCurtain = function (data, x, y, prefix) { if (data.async) { core.setCurtain(data.color, data.time); - core.setFlag('__color__', data.color || null); + if (data.color == null || data.keep) core.setFlag('__color__', data.color || null); core.doAction(); } else { core.setCurtain(data.color, data.time, function () { - core.setFlag('__color__', data.color || null); + if (data.color == null || data.keep) core.setFlag('__color__', data.color || null); core.doAction(); }); } @@ -1458,7 +1454,7 @@ events.prototype._action_screenFlash = function (data, x, y, prefix) { events.prototype._action_setWeather = function (data, x, y, prefix) { core.setWeather(data.name, data.level); - if (data.name == 'rain' || data.name == 'snow' || data.name == 'fog') + if ((data.name == 'rain' || data.name == 'snow' || data.name == 'fog') && data.keep) core.setFlag('__weather__', [data.name, data.level]); else core.removeFlag('__weather__'); core.doAction();