diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4
index 38cf35bf..78f1cf66 100644
--- a/_server/MotaAction.g4
+++ b/_server/MotaAction.g4
@@ -2564,9 +2564,7 @@ expression
//todo 修改recieveOrder,根据Arithmetic_List_0不同的值设定不同的recieveOrder
var code = expression_0 + Arithmetic_List_0 + expression_1;
var ops = {
- '^': 'Math.pow('+expression_0+','+expression_1+')',
- '和': expression_0+' && '+expression_1,
- '或': expression_0+' || '+expression_1,
+ '^': 'Math.pow('+expression_0+','+expression_1+')'
}
if (ops[Arithmetic_List_0])code = ops[Arithmetic_List_0];
var orders = {
@@ -2581,8 +2579,8 @@ var orders = {
'<': Blockly.JavaScript.ORDER_RELATIONAL,
'>=': Blockly.JavaScript.ORDER_RELATIONAL,
'<=': Blockly.JavaScript.ORDER_RELATIONAL,
- '和': Blockly.JavaScript.ORDER_LOGICAL_AND,
- '或': Blockly.JavaScript.ORDER_LOGICAL_OR
+ '&&': Blockly.JavaScript.ORDER_LOGICAL_AND,
+ '||': Blockly.JavaScript.ORDER_LOGICAL_OR
}
return [code, orders[Arithmetic_List_0]];
*/;
@@ -2774,8 +2772,8 @@ ShopUse_List
/*ShopUse_List ['money','exp']*/;
Arithmetic_List
- : '+'|'-'|'*'|'/'|'^'|'=='|'!='|'>'|'<'|'>='|'<='|'和'|'或'
- ;
+ : '+'|'-'|'*'|'/'|'^'|'=='|'!='|'>'|'<'|'>='|'<='|'且'|'或'
+ /*Arithmetic_List ['+','-','*','/','^','==','!=','>','<','>=','<=','&&','||']*/;
AssignOperator_List
: '='|'+='|'-='|'*='|'/='|'**='|'//='|'%='
diff --git a/_server/MotaActionParse.js b/_server/MotaActionParse.js
index 4dabb99d..3b723d2e 100644
--- a/_server/MotaActionParse.js
+++ b/_server/MotaActionParse.js
@@ -997,12 +997,13 @@ ActionParser.prototype.matchEvalAtom = function(args) {
}
ActionParser.prototype.matchEvalCompare=function(args, isShadow){
- var raw=args[0].replace(/>/g,'>').replace(/</g,'<')
+ if (MotaActionFunctions.disableExpandCompare) return {ret:false};
+ var raw=args[0].replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"').replace(/ /g,' ').replace(/&/g,'&')
if (raw[0]+raw.slice(-1)=='()') raw=raw.slice(1,-1);
var str=raw
var xml=MotaActionBlocks['expression_arithmetic_0'].xmlText
- if (!/<=|<|>=|>|==|!=/.exec(str)) return {ret:false};
- str=str.replace(/[^<>=!()]/g,' ')
+ if (!/<=|<|>=|>|==|!=|&&|\|\|/.exec(str)) return {ret:false};
+ str=str.replace(/[^<>=!()&|]/g,' ')
// 处理括号匹配
var old;
do {
@@ -1010,11 +1011,11 @@ ActionParser.prototype.matchEvalCompare=function(args, isShadow){
str=str.replace(/\([^()]*\)/g,function(v){return Array.from({length:v.length+1}).join(' ')})
} while (old!=str);
// 按优先级依次寻找以下符号
- var oplist=['<','<=','>','>=','==','!=']
+ var oplist=['<','<=','>','>=','==','!=','&&','||'].reverse()
for (var index = 0,op; op=oplist[index]; index++) {
- var match=new RegExp('(?<= )'+op+'(?= )').exec(str)
+ var match=new RegExp('(?<= )'+(op=='||'?'\\|\\|':op)+'(?= )').exec(str)
if (!match) continue;
- args=[this.expandEvalBlock([raw.slice(0,match.index)],isShadow),op,this.expandEvalBlock([raw.slice(match.index+op.length)],isShadow)]
+ args=[this.expandEvalBlock([raw.slice(0,match.index)],isShadow),(op=='&&'?'&&':op),this.expandEvalBlock([raw.slice(match.index+op.length)],isShadow)]
return {ret:true,xml:xml,args:args}
}
return {ret:false}
@@ -1248,6 +1249,7 @@ MotaActionFunctions.pattern.replaceEnemyList = [
];
MotaActionFunctions.disableReplace = false;
+MotaActionFunctions.disableExpandCompare = false;
MotaActionFunctions.replaceToName_token = function (str) {
if (!str || MotaActionFunctions.disableReplace) return str;
diff --git a/_server/config.json b/_server/config.json
index 9c9888dc..4965dae4 100644
--- a/_server/config.json
+++ b/_server/config.json
@@ -1 +1 @@
-{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}}
\ No newline at end of file
+{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"disableBlocklyExpandCompare":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}}
\ No newline at end of file
diff --git a/_server/editor.js b/_server/editor.js
index 6f282c4c..31d1f954 100644
--- a/_server/editor.js
+++ b/_server/editor.js
@@ -87,6 +87,8 @@ function editor() {
ratio : 1,
// blockly转义
disableBlocklyReplace: false,
+ // blockly展开比较
+ disableBlocklyExpandCompare: false,
// 绑定机关门事件相关
bindSpecialDoor: {
diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js
index df6ed146..b7bc1166 100644
--- a/_server/editor_blockly.js
+++ b/_server/editor_blockly.js
@@ -497,6 +497,16 @@ function omitedcheckUpdateFunction(event) {
alert("已" + (replaceCheckbox.checked ? "开启" : "关闭") + "中文变量名替换!\n关闭并重开事件编辑器以生效。");
}
+ editor.uivalues.disableBlocklyExpandCompare = editor.config.get("disableBlocklyExpandCompare", false);
+ var expandCompareCheckbox = document.getElementById('blocklyExpandCompare');
+ expandCompareCheckbox.checked = !editor.uivalues.disableBlocklyExpandCompare;
+
+ editor_blockly.triggerExpandCompare = function () {
+ editor.uivalues.disableBlocklyExpandCompare = !expandCompareCheckbox.checked;
+ editor.config.set("disableBlocklyExpandCompare", !expandCompareCheckbox.checked);
+ if (MotaActionFunctions) MotaActionFunctions.disableExpandCompare = !expandCompareCheckbox.checked;
+ }
+
var input_ = '';
editor_blockly.runOne = function () {
//var printf = console.log;
@@ -527,6 +537,7 @@ function omitedcheckUpdateFunction(event) {
input_ = xhr.responseText;
editor_blockly.runOne();
MotaActionFunctions.disableReplace = editor.uivalues.disableBlocklyReplace;
+ MotaActionFunctions.disableExpandCompare = editor.uivalues.disableBlocklyExpandCompare;
}
xhr.open('GET', '_server/MotaAction.g4', true);
xhr.send(null);
diff --git a/editor-mobile.html b/editor-mobile.html
index 5fdeb1f2..37949d9b 100644
--- a/editor-mobile.html
+++ b/editor-mobile.html
@@ -234,6 +234,8 @@
开启中文名替换
+
+ 展开值块逻辑运算
diff --git a/editor.html b/editor.html
index 77cb455c..17ff7d97 100644
--- a/editor.html
+++ b/editor.html
@@ -229,6 +229,8 @@
开启中文名替换
+
+ 展开值块逻辑运算