From dc5326c982aa6dfaa246b3c91936fe8379ab4d2c Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 30 Jul 2021 22:31:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A3=85=E5=A4=87=E7=A9=BF=E4=B8=8A=20&=20?= =?UTF-8?q?=E8=84=B1=E4=B8=8B=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 10 ++++++---- _server/MotaActionParser.js | 3 ++- libs/actions.js | 4 ++++ libs/core.js | 38 ++++++++++++++++++++++++++++++++----- libs/events.js | 28 ++++++++++++++++++--------- 5 files changed, 64 insertions(+), 19 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index b99e8246..6708c405 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -456,7 +456,7 @@ return code; // equip 事件编辑器入口之一 equip_m - : '装备' '类型' EvalString '装备动画(第一个装备格有效)' IdString? BGNL? '数值提升项' equipList+ '百分比提升项' equipList+ '此道具cls须为equips并设置canUseItemEffect' BEND + : '装备' '类型' EvalString '装备动画(第一个装备格有效)' IdString? BGNL? '数值提升项' equipList+ '百分比提升项' equipList+ '穿上时事件' action+ '脱下时事件' action+ '此道具cls须为equips并设置canUseItemEffect' BEND /* equip_m @@ -468,7 +468,9 @@ if (!/^\d+$/.test(EvalString_0)) { EvalString_0 = '"' + EvalString_0 + '"'; } IdString_0 = IdString_0 && (', "animate": "'+IdString_0+'"'); -var code = '{"type": '+EvalString_0+IdString_0+', "value": {\n'+equipList_0+'\n}, "percentage": {\n'+equipList_1+'\n}}'; +if (action_0.trim()) action_0 = ', "equipEvent": [\n' + action_0 + ']'; +if (action_1.trim()) action_1 = ', "unequipEvent": [\n' + action_1 + ']'; +var code = '{"type": '+EvalString_0+IdString_0+', "value": {\n'+equipList_0+'\n}, "percentage": {\n'+equipList_1+'\n}'+action_0+action_1+'}'; return code; */; @@ -2034,7 +2036,7 @@ return code; */; unloadEquip_s - : '卸下装备孔' Int '的装备' Newline + : '卸下第' Int '格装备孔的装备' Newline /* unloadEquip_s @@ -3868,7 +3870,7 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC]; equip_e - : '装备孔:' Int + : '第' Int '格装备孔' /* equip_e diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index 2118755d..8505d954 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -82,7 +82,8 @@ ActionParser.prototype.parse = function (obj,type) { }) return text_choices; } - return MotaActionBlocks['equip_m'].xmlText([obj.type, obj.animate, buildEquip(obj.value), buildEquip(obj.percentage)]); + return MotaActionBlocks['equip_m'].xmlText([obj.type, obj.animate, buildEquip(obj.value), buildEquip(obj.percentage), + this.parseList(obj.equipEvent), this.parseList(obj.unequipEvent)]); case 'doorInfo': if(!obj) obj={}; diff --git a/libs/actions.js b/libs/actions.js index 4c1f2270..15a48294 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1503,6 +1503,7 @@ actions.prototype._clickToolbox = function (x, y) { if (x >= this.LAST - 2 && y == this.LAST) { core.playSound('取消'); core.ui.closePanel(); + core.checkAutoEvents(); return; } @@ -1678,6 +1679,7 @@ actions.prototype._keyUpToolbox = function (keycode) { if (keycode == 84 || keycode == 27 || keycode == 88) { core.playSound('取消'); core.ui.closePanel(); + core.checkAutoEvents(); return; } if (core.status.event.data == null) return; @@ -1704,6 +1706,7 @@ actions.prototype._clickEquipbox = function (x, y) { if (x >= this.LAST - 2 && y == this.LAST) { core.playSound('取消'); core.ui.closePanel(); + core.checkAutoEvents(); return; } @@ -1861,6 +1864,7 @@ actions.prototype._keyUpEquipbox = function (keycode, altKey) { if (keycode == 81 || keycode == 27 || keycode == 88) { core.playSound('取消'); core.ui.closePanel(); + core.checkAutoEvents(); return; } if (!core.status.event.data.selectId) return; diff --git a/libs/core.js b/libs/core.js index c87f809e..d82d9592 100644 --- a/libs/core.js +++ b/libs/core.js @@ -292,6 +292,13 @@ core.prototype._init_flags = function () { document.title = core.firstData.title + " - HTML5魔塔"; document.getElementById("startLogo").innerText = core.firstData.title; (core.firstData.shops||[]).forEach(function (t) { core.initStatus.shops[t.id] = t; }); + + core.maps._initFloors(); + // 初始化怪物、道具等 + core.material.enemys = core.enemys.getEnemys(); + core.material.items = core.items.getItems(); + core.material.icons = core.icons.getIcons(); + // 初始化自动事件 for (var floorId in core.floors) { var autoEvents = core.floors[floorId].autoEvent || {}; @@ -312,7 +319,33 @@ core.prototype._init_flags = function () { } } } + // 道具的穿上/脱下,视为自动事件 + for (var equipId in core.material.items) { + var equip = core.material.items[equipId]; + if (equip.cls != 'equips' || !equip.equip) continue; + if (!equip.equip.equipEvent && !equip.equip.unequipEvent) continue; + var equipFlag = '_equipEvent_' + equipId; + var autoEvent1 = { + symbol: "_equipEvent_" + equipId, + currentFloor: false, + multiExecute: true, + condition: "core.hasEquip('" + equipId + "') && !core.hasFlag('"+equipFlag+"')", + data: core.precompile([{"type": "setValue", "name": "flag:" + equipFlag, "value": "true"}].concat(equip.equip.equipEvent||[])), + }; + var autoEvent2 = { + symbol: "_unequipEvent_" + equipId, + currentFloor: false, + multiExecute: true, + condition: "!core.hasEquip('" + equipId + "') && core.hasFlag('"+equipFlag+"')", + data: core.precompile([{"type": "setValue", "name": "flag:" + equipFlag, "value": "null"}].concat(equip.equip.unequipEvent||[])), + }; + core.initStatus.autoEvents.push(autoEvent1); + core.initStatus.autoEvents.push(autoEvent2); + } + core.initStatus.autoEvents.sort(function (e1, e2) { + if (e1.floorId == null) return 1; + if (e2.floorId == null) return -1; if (e1.priority != e2.priority) return e2.priority - e1.priority; if (e1.floorId != e2.floorId) return core.floorIds.indexOf(e1.floorId) - core.floorIds.indexOf(e2.floorId); if (e1.x != e2.x) return e1.x - e2.x; @@ -320,11 +353,6 @@ core.prototype._init_flags = function () { return e1.index - e2.index; }) - core.maps._initFloors(); - // 初始化怪物、道具等 - core.material.enemys = core.enemys.getEnemys(); - core.material.items = core.items.getItems(); - core.material.icons = core.icons.getIcons(); } core.prototype._init_sys_flags = function () { diff --git a/libs/events.js b/libs/events.js index 298215a2..338ae6f7 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1104,15 +1104,25 @@ events.prototype.checkAutoEvents = function () { core.autoEventExecuting(symbol, true); core.autoEventExecuted(symbol, true); - - var event = [ - {"type": "function", "function": - "function() { core.pushEventLoc(" + x + ", " + y + ", '" + floorId + "' ); }"}, - // 用do-while(0)包一层防止break影响事件流 - {"type": "dowhile", "condition": "false", "data": autoEvent.data}, - {"type": "function", "function": - "function() { core.popEventLoc(); core.autoEventExecuting('" + symbol + "', false); }"} - ]; + + var event; + if (x == null && y == null) { + event = [ + // 用do-while(0)包一层防止break影响事件流 + {"type": "dowhile", "condition": "false", "data": autoEvent.data}, + {"type": "function", "function": + "function() { core.autoEventExecuting('" + symbol + "', false); }"} + ]; + } else { + event = [ + {"type": "function", "function": + "function() { core.pushEventLoc(" + x + ", " + y + ", '" + floorId + "' ); }"}, + // 用do-while(0)包一层防止break影响事件流 + {"type": "dowhile", "condition": "false", "data": autoEvent.data}, + {"type": "function", "function": + "function() { core.popEventLoc(); core.autoEventExecuting('" + symbol + "', false); }"} + ]; + } if (autoEvent.delayExecute) delay.push(event); From b8ddb2e1673a0bc8c68f715f98f891291e54a28c Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 30 Jul 2021 23:22:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=AD=89=E5=BE=85=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E4=BB=85=E6=A3=80=E6=B5=8B=E5=AD=90=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 29 ++++++++++++++++++++------ _server/MotaActionParser.js | 9 +++++++-- _server/editor_blocklyconfig.js | 1 + _server/editor_mappanel.js | 10 +++++++++ _server/editor_ui.js | 5 +++++ libs/actions.js | 36 +++++++++++++++++++-------------- libs/events.js | 20 ++++++++++++++---- 7 files changed, 83 insertions(+), 27 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 6708c405..9d137c8e 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2982,19 +2982,20 @@ return code; wait_s - : '等待用户操作并获得按键或点击信息' '超时毫秒数' Int BGNL? Newline waitContext* BEND Newline + : '等待用户操作并获得按键或点击信息' '仅检测子块' Bool '超时毫秒数' Int BGNL? Newline waitContext* BEND Newline /* wait_s tooltip : wait: 等待用户操作并获得按键或点击信息 helpUrl : /_docs/#/instruction -default : [0] +default : [true,0] colour : this.soundColor +Bool_0 = Bool_0?(', "forceChild": true'):''; Int_0 = Int_0?(', "timeout": ' + Int_0):''; waitContext_0 = waitContext_0 ? (', "data": [\n' + waitContext_0 + ']') : ''; var collapsed=block.isCollapsed()?', "_collapsed": true':''; var disabled=block.isEnabled()?'':', "_disabled": true'; -var code = '{"type": "wait"' + Int_0 + collapsed + disabled + waitContext_0 + '},\n'; +var code = '{"type": "wait"' + Bool_0 + Int_0 + collapsed + disabled + waitContext_0 + '},\n'; return code; */; @@ -3003,11 +3004,12 @@ waitContext : waitContext_1 | waitContext_2 | waitContext_3 + | waitContext_4 | waitContext_empty; waitContext_1 - : '按键的场合' '键值' EvalString '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline + : '按键的场合:' '键值' EvalString '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline /* waitContext_1 tooltip : wait: 等待用户操作并获得按键或点击信息 @@ -3026,7 +3028,7 @@ return code; waitContext_2 - : '点击的场合' '像素x范围' PosString '~' PosString '; y范围' PosString '~' PosString '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline + : '点击的场合:' '像素x范围' PosString '~' PosString '; y范围' PosString '~' PosString '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline /* waitContext_2 tooltip : wait: 等待用户操作并获得按键或点击信息 @@ -3042,11 +3044,26 @@ return code; */; waitContext_3 - : '超时的场合' '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline + : '自定义条件的场合:' expression '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline /* waitContext_3 tooltip : wait: 等待用户操作并获得按键或点击信息 helpUrl : /_docs/#/instruction +default : ["true",false] +colour : this.subColor +Bool_0 = Bool_0?', "break": true':''; +var collapsed=block.isCollapsed()?', "_collapsed": true':''; +var disabled=block.isEnabled()?'':', "_disabled": true'; +var code = '{"case": "condition", "condition": "'+expression_0+'"'+Bool_0+collapsed+disabled+', "action": [\n' + action_0 + ']},\n'; +return code; +*/; + +waitContext_4 + : '超时的场合:' '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline + +/* waitContext_4 +tooltip : wait: 等待用户操作并获得按键或点击信息 +helpUrl : /_docs/#/instruction colour : this.subColor default : [false] Bool_0 = Bool_0?', "break": true':''; diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index 8505d954..9b40faba 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -906,15 +906,19 @@ ActionParser.prototype.parseAction = function() { case_waitList = MotaActionFunctions.xmlText('waitContext_2',[ caseNow.px[0], caseNow.px[1], caseNow.py[0], caseNow.py[1], caseNow["break"] || false, this.insertActionList(caseNow.action), case_waitList ], /* isShadow */false, /*comment*/ null, /*collapsed*/ caseNow._collapsed, /*disabled*/ caseNow._disabled); - } else if (caseNow["case"] == "timeout") { + } else if (caseNow["case"] == "condition") { case_waitList = MotaActionFunctions.xmlText('waitContext_3',[ + this.expandEvalBlock([caseNow.condition]), caseNow["break"] || false, this.insertActionList(caseNow.action), case_waitList + ], /* isShadow */false, /*comment*/ null, /*collapsed*/ caseNow._collapsed, /*disabled*/ caseNow._disabled); + } else if (caseNow["case"] == "timeout") { + case_waitList = MotaActionFunctions.xmlText('waitContext_4',[ caseNow["break"] || false, this.insertActionList(caseNow.action), case_waitList ], /* isShadow */false, /*comment*/ null, /*collapsed*/ caseNow._collapsed, /*disabled*/ caseNow._disabled); } } } this.next = MotaActionFunctions.xmlText('wait_s',[ - data.timeout||0,case_waitList, this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed, /*disabled*/ data._disabled); + data.forceChild||false,data.timeout||0,case_waitList, this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed, /*disabled*/ data._disabled); break; case "waitAsync": // 等待所有异步事件执行完毕 this.next = MotaActionBlocks['waitAsync_s'].xmlText([ @@ -1334,6 +1338,7 @@ ActionParser.prototype.expandIdBlock = function(args, isShadow, comment) { ActionParser.prototype.expandEvalBlock = function(args, isShadow, comment) { args[0]=MotaActionFunctions.replaceFromName(args[0]) var xml=MotaActionBlocks['evalString_e'].xmlText + if (args[0].indexOf('\n') >= 0 || args[0].indexOf('\\n') >= 0) return xml(args, isShadow, comment); var ret=this.matchId(args) if (ret.ret){ xml=ret.xml; diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index cba73bcf..5951b0d8 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -193,6 +193,7 @@ editor_blocklyconfig=(function(){ MotaActionFunctions.actionParser.parseList({"type": "wait", "timeout": 0, "data": [ {"case": "keyboard", "keycode": "13,32", "action": [{"type": "comment", "text": "当按下回车(keycode=13)或空格(keycode=32)时执行此事件\n超时剩余时间会写入flag:timeout"}]}, {"case": "mouse", "px": [0,32], "py": [0,32], "action": [{"type": "comment", "text": "当点击地图左上角时执行此事件\n超时剩余时间会写入flag:timeout"}]}, + {"case": "condition", "condition": "flag:type==0\n&&flag:keycode==13", "action": [{"type": "comment", "text": "当满足自定义条件时会执行此事件\n超时剩余时间会写入flag:timeout"}]}, {"case": "timeout", "action": [{"type": "comment", "text": "当超时未操作时执行此事件"}]}, ]}), MotaActionBlocks['waitAsync_s'].xmlText(), diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js index 3ac4b0bd..1170537c 100644 --- a/_server/editor_mappanel.js +++ b/_server/editor_mappanel.js @@ -407,6 +407,11 @@ editor_mappanel_wrapper = function (editor) { var index = editor.core.floorIds.indexOf(editor.currentFloorId); var toId = editor.currentFloorId; + var saveFloor = document.getElementById('saveFloor'); + if (saveFloor && saveFloor.classList.contains('highlight')) { + return; + } + if (direct > 0 && index < editor.core.floorIds.length - 1) toId = editor.core.floorIds[index + 1]; else if (direct < 0 && index > 0) @@ -433,6 +438,11 @@ editor_mappanel_wrapper = function (editor) { } editor.uifunctions.undoFloor_click = function () { + var saveFloor = document.getElementById('saveFloor'); + if (saveFloor && saveFloor.classList.contains('highlight')) { + return; + } + var toId = editor.uivalues.recentFloors.pop(); if (toId == null || toId == editor.currentFloorId) return; diff --git a/_server/editor_ui.js b/_server/editor_ui.js index c85d9f15..e4db4ae3 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -164,6 +164,11 @@ editor_ui_wrapper = function (editor) { // PGUP和PGDOWN切换楼层 if (e.keyCode == 33 || e.keyCode == 34) { e.preventDefault(); + var saveFloor = document.getElementById('saveFloor'); + if (saveFloor && saveFloor.classList.contains('highlight')) { + return; + } + var index = editor.core.floorIds.indexOf(editor.currentFloorId); var nextIndex = index + (e.keyCode == 33 ? 1 : -1); if (nextIndex >= 0 && nextIndex < editor.core.floorIds.length) { diff --git a/libs/actions.js b/libs/actions.js index 15a48294..1c21c452 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -777,16 +777,18 @@ actions.prototype._sys_onmousewheel = function (direct) { // wait事件 if (core.status.lockControl && core.status.event.id == 'action' && core.status.event.data.type == 'wait') { - clearTimeout(core.status.event.interval); var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; - delete core.status.event.timeout; core.setFlag('type', 0); var keycode = direct == 1 ? 33 : 34; core.setFlag('keycode', keycode); core.setFlag('timeout', timeout); - core.status.route.push("input:" + (1e8 * timeout + keycode)); - core.events.__action_wait_afterGet(core.status.event.data.current); - core.doAction(); + var executed = core.events.__action_wait_afterGet(core.status.event.data.current); + if (executed || !core.status.event.data.current.forceChild) { + core.status.route.push("input:" + (1e8 * timeout + keycode)); + clearTimeout(core.status.event.interval); + delete core.status.event.timeout; + core.doAction(); + } return; } @@ -1040,18 +1042,20 @@ actions.prototype._clickAction = function (x, y, px, py) { } if (core.status.event.data.type == 'wait') { - clearTimeout(core.status.event.interval); var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; - delete core.status.event.timeout; core.setFlag('type', 1); core.setFlag('x', x); core.setFlag('y', y); core.setFlag('px', px); core.setFlag('py', py); core.setFlag('timeout', timeout); - core.status.route.push("input:" + (1e8 * timeout + 1000000 + 1000 * px + py)); - core.events.__action_wait_afterGet(core.status.event.data.current); - core.doAction(); + var executed = core.events.__action_wait_afterGet(core.status.event.data.current); + if (executed || !core.status.event.data.current.forceChild) { + core.status.route.push("input:" + (1e8 * timeout + 1000000 + 1000 * px + py)); + clearTimeout(core.status.event.interval); + delete core.status.event.timeout; + core.doAction(); + } return; } @@ -1134,15 +1138,17 @@ actions.prototype._keyUpAction = function (keycode) { return; } if (core.status.event.data.type == 'wait') { - clearTimeout(core.status.event.interval); var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; - delete core.status.event.timeout; core.setFlag('type', 0); core.setFlag('keycode', keycode); core.setFlag('timeout', timeout); - core.status.route.push("input:" + (1e8 * timeout + keycode)); - core.events.__action_wait_afterGet(core.status.event.data.current); - core.doAction(); + var executed = core.events.__action_wait_afterGet(core.status.event.data.current); + if (executed || !core.status.event.data.current.forceChild) { + core.status.route.push("input:" + (1e8 * timeout + keycode)); + clearTimeout(core.status.event.interval); + delete core.status.event.timeout; + core.doAction(); + } return; } if (core.status.event.data.type == 'choices') { diff --git a/libs/events.js b/libs/events.js index 338ae6f7..528f31dd 100644 --- a/libs/events.js +++ b/libs/events.js @@ -2371,7 +2371,7 @@ events.prototype.__action_wait_getValue = function (value) { } events.prototype.__action_wait_afterGet = function (data) { - if (!data.data) return; + if (!data.data) return false; var todo = []; var stop = false; data.data.forEach(function (one) { @@ -2396,20 +2396,32 @@ events.prototype.__action_wait_afterGet = function (data) { if (one["break"]) stop = true; } } + if (one["case"] == "condition") { + var condition = false; + try { condition = core.calValue(one.condition); } catch (e) {} + if (condition) { + core.push(todo, one.action); + if (one["break"]) stop = true; + } + } if (one["case"] == "timeout" && core.getFlag("type") == -1) { core.push(todo, one.action); if (one["break"]) stop = true; } }) - if (todo.length > 0) + if (todo.length > 0) { core.insertAction(todo); + return true; + } + return false; } events.prototype._precompile_wait = function (data) { if (data.data) { data.data.forEach(function (v) { - if (v.px) v.px = this.__precompile_array(v.px); - if (v.py) v.py = this.__precompile_array(v.py); + if (v.px != null) v.px = this.__precompile_array(v.px); + if (v.py != null) v.py = this.__precompile_array(v.py); + if (v.condition != null) v.condition = this.__precompile_array(v.condition); v.action = this.precompile(v.action); }, this); } From df763b6b95c2b73d08ec1afe9ff2f7c007f15f82 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sat, 31 Jul 2021 00:23:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=9B=BE=E5=9D=97=E7=A2=B0=E8=A7=A6?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 3 ++- _server/editor_blockly.js | 6 ++++++ _server/table/comment.js | 7 +++++++ libs/events.js | 16 ++++++++++++++++ libs/ui.js | 2 +- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 9d137c8e..bc8dceaa 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -3009,13 +3009,14 @@ waitContext waitContext_1 - : '按键的场合:' '键值' EvalString '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline + : '按键的场合:' '键值(右键查表)' EvalString '不进行剩余判定' Bool BGNL? Newline action+ BEND Newline /* waitContext_1 tooltip : wait: 等待用户操作并获得按键或点击信息 helpUrl : /_docs/#/instruction colour : this.subColor default : ["",false] +menu : [["查询键值表", "editor_blockly.showKeyCodes()"]] if (!/^\d+(,\d+)*$/.test(EvalString_0)) { throw new Error('键值必须是正整数,可以以逗号分隔'); } diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 7706820b..cc0b53b2 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -414,6 +414,12 @@ editor_blockly = function () { } } + editor_blockly.showKeyCodes = function () { + alert('键值查询表:\nA65 B66 C67 D68 E69 F70 G71 H72 I73 J74 K75 L76 M77\n' + +'N78 O79 P80 Q81 R82 S83 T84 U85 V86 W87 X88 Y89 Z90\n0:48 1:49 2:50 3:51 4:52 5:53 6:54 7:55 8:56 9:57\n' + +'空格:13 回车:32 ESC:27 后退:8 Tab:9 Shift:16 Ctrl:17 Alt:18\nPgUp:33 PgDn:34 左:37 上:38 右:39 下:40\n更多键值请自行百度查表') + } + editor_blockly.lastUsedType=[ 'text_0_s', 'comment_s', diff --git a/_server/table/comment.js b/_server/table/comment.js index 916bdffd..72d68466 100644 --- a/_server/table/comment.js +++ b/_server/table/comment.js @@ -320,6 +320,13 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "碰触脚本", "_data": "触碰到该图块时自动执行的脚本内容;此脚本会在该点的触发器执行前执行" }, + "event": { + "_leaf": true, + "_type": "event", + "_event": "item", + "_docs": "碰触事件", + "_data": "触碰到该图块时自动执行的事件内容;如果存在本事件则不会执行默认触发器" + }, "cannotOut": { "_leaf": true, "_type": "checkboxSet", diff --git a/libs/events.js b/libs/events.js index 528f31dd..38695075 100644 --- a/libs/events.js +++ b/libs/events.js @@ -344,6 +344,14 @@ events.prototype.trigger = function (x, y, callback) { } catch (e) { main.log(e); } } + // 碰触事件 + if (block.event.event) { + core.clearRouteFolding(); + core.insertAction(block.event.event, block.x, block.y); + // 不再执行该点的系统事件 + return _executeCallback(); + } + if (block.event.trigger && block.event.trigger != 'null') { var noPass = block.event.noPass, trigger = block.event.trigger; if (noPass) core.clearAutomaticRouteNode(x, y); @@ -368,6 +376,14 @@ events.prototype._trigger_inAction = function (x, y) { eval(block.event.script); } catch (e) { main.log(e); } + // 碰触事件 + if (block.event.event) { + core.clearRouteFolding(); + core.insertAction(block.event.event, block.x, block.y); + // 不再执行该点的系统事件 + return core.doAction(); + } + if (block.event.trigger && block.event.trigger != 'null') { this.setEvents(null, x, y); if (block.event.trigger == 'action') { diff --git a/libs/ui.js b/libs/ui.js index 6e386e6e..d93c474a 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2439,7 +2439,7 @@ ui.prototype.drawFly = function(page) { } var size = this.PIXEL - 143; core.strokeRect('ui', 20, 100, size, size, '#FFFFFF', 2); - core.drawThumbnail(floorId, null, {ctx: 'ui', x: 20, y: 100, size: size}); + core.drawThumbnail(floorId, null, {ctx: 'ui', x: 20, y: 100, size: size, damage: true}); } ////// 绘制中心对称飞行器