From 9264e7dfe5d78b3368ab202594183c8cd2465304 Mon Sep 17 00:00:00 2001 From: oc Date: Mon, 29 Apr 2019 20:10:42 +0800 Subject: [PATCH] insertAction commonEvent do-while --- _server/MotaAction.g4 | 2 +- libs/events.js | 5 ++++- libs/utils.js | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 43d375fd..d8593e39 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1757,7 +1757,7 @@ return code; */; break_s - : '跳出循环' Newline + : '跳出当前循环或公共事件' Newline /* break_s tooltip : break:跳出循环, 如果break事件不在任何循环中被执行,则和exit等价,即会立刻结束当前事件! diff --git a/libs/events.js b/libs/events.js index 16ade8b0..2befed36 100644 --- a/libs/events.js +++ b/libs/events.js @@ -843,7 +843,10 @@ events.prototype.insertAction = function (action, x, y, callback, addToLast) { // ------ 判定commonEvent var commonEvent = this.getCommonEvent(action); - if (commonEvent instanceof Array) action = commonEvent; + if (commonEvent instanceof Array) { + // 将公共事件视为一个do-while事件插入执行,可被break跳出 + action = [{"type": "dowhile", "condition": "false", "data": commonEvent}]; + } if (!action) return; if (core.status.event.id != 'action') { diff --git a/libs/utils.js b/libs/utils.js index afe6a241..b5107087 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -248,7 +248,7 @@ utils.prototype.removeLocalForage = function (key, successCallback, errorCallbac } utils.prototype.setGlobal = function (key, value) { - if (core.status.replay.replaying) return; + if (core.isReplaying()) return; core.setLocalStorage(key, value); } @@ -262,7 +262,7 @@ utils.prototype.getGlobal = function (key, defaultValue) { } else { core.control._replay_error(action); - return defaultValue; + return core.getLocalStorage(key, defaultValue); } } else {