diff --git a/_docs/event.md b/_docs/event.md index c68f267c..866a771c 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -1384,6 +1384,10 @@ async可选,如果为true则会异步执行(即不等待当前事件执行 该事件会显示失败页面,并重新开始游戏。 +### restart:直接回到标题界面 + +`{"type": "restart"}` 会中断一切执行的事件,并直接直接返回标题界面。 + ### callBook:呼出怪物手册 `{"type": "callBook"}` 可以呼出怪物手册,玩家可以自由查看当前楼层怪物数据和详细信息。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 5db9a805..6906166b 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -324,6 +324,7 @@ action | setVolume_s | win_s | lose_s + | restart_s | if_s | if_1_s | switch_s @@ -581,7 +582,7 @@ show_s tooltip : show: 将禁用事件启用,楼层和动画时间可不填,xy可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=show%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E7%A6%81%E7%94%A8%E4%BA%8B%E4%BB%B6%E5%90%AF%E7%94%A8 default : ["","","",500,false] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -614,7 +615,7 @@ hide_s tooltip : hide: 将一个启用事件禁用,所有参数均可不填,代表禁用事件自身,xy可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=hide%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E5%90%AF%E7%94%A8%E4%BA%8B%E4%BB%B6%E7%A6%81%E7%94%A8 default : ["","","",500,false] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -736,7 +737,7 @@ setBlock_s /* setBlock_s tooltip : setBlock:设置某个图块,忽略坐标楼层则为当前事件 helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 -colour : this.dataColor +colour : this.mapColor default : ["yellowDoor","","",""] var floorstr = ''; if (PosString_0 && PosString_1) { @@ -755,7 +756,7 @@ showFloorImg_s tooltip : showFloorImg: 显示一个贴图,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be default : ["","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -786,7 +787,7 @@ hideFloorImg_s tooltip : hideFloorImg: 隐藏一个贴图,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be default : ["","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -817,7 +818,7 @@ showBgFgMap_s tooltip : showBgFgMap: 显示图层块,即背景图层/前景图层的某些图块,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be default : ["bg","","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -848,7 +849,7 @@ hideBgFgMap_s tooltip : hideBgFgMap: 隐藏图层块,即背景图层/前景图层的某些图块,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be default : ["bg","","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -878,7 +879,7 @@ setBgFgBlock_s /* setBgFgBlock_s tooltip : setBgFgBlock:设置某个图层块,忽略坐标楼层则为当前点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 -colour : this.dataColor +colour : this.mapColor default : ["bg","yellowDoor","","",""] var floorstr = ''; if (PosString_0 && PosString_1) { @@ -989,7 +990,7 @@ openDoor_s tooltip : openDoor: 开门,楼层可不填表示当前层 helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 default : ["","","",false] -colour : this.dataColor +colour : this.mapColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); var floorstr = ''; if (PosString_0 && PosString_1) { @@ -1008,7 +1009,7 @@ closeDoor_s tooltip : closeDoor: 关门事件,需要该点本身无事件 helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 default : ["","","yellowDoor"] -colour : this.dataColor +colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; @@ -1097,7 +1098,7 @@ disableShop_s tooltip : 全局商店 helpUrl : https://h5mota.com/games/template/docs/#/event?id=disableshop%EF%BC%9A%E7%A6%81%E7%94%A8%E4%B8%80%E4%B8%AA%E5%85%A8%E5%B1%80%E5%95%86%E5%BA%97 default : ["shop1"] -colour : this.eventColor +colour : this.dataColor var code = '{"type": "disableShop", "id": "'+IdString_0+'"},\n'; return code; */; @@ -1352,7 +1353,7 @@ move_s tooltip : move: 让某个NPC/怪物移动,位置可不填代表当前事件 helpUrl : https://h5mota.com/games/template/docs/#/event?id=move%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AAnpc%E6%80%AA%E7%89%A9%E7%A7%BB%E5%8A%A8 default : ["","",500,false,false,"上右3下2左上左2"] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; @@ -1387,7 +1388,7 @@ jump_s tooltip : jump: 让某个NPC/怪物跳跃 helpUrl : https://h5mota.com/games/template/docs/#/event?id=jump%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AANPC%2F%E6%80%AA%E7%89%A9%E8%B7%B3%E8%B7%83 default : ["","","","",500,true,false] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { floorstr += ', "from": ['+PosString_0+','+PosString_1+']'; @@ -1550,6 +1551,17 @@ var code = '{"type": "lose", "reason": "'+EvalString_0+'"},\n'; return code; */; +restart_s + : '直接回到标题界面' Newline + + +/* restart_s +tooltip : restart: 直接回到标题界面 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=restart%ef%bc%9a%e7%9b%b4%e6%8e%a5%e5%9b%9e%e5%88%b0%e6%a0%87%e9%a2%98%e7%95%8c%e9%9d%a2 +var code = '{"type": "restart"},\n'; +return code; +*/; + input_s : '接受用户输入数字,提示' ':' EvalString Newline @@ -2142,6 +2154,7 @@ this.evisitor.dataColor=130; this.evisitor.eventColor=220; this.evisitor.soundColor=20; this.evisitor.commentColor=285; +this.evisitor.mapColor=175; */ /* Function_1 @@ -2687,6 +2700,10 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['lose_s'].xmlText([ data.reason,this.next]); break; + case "restart": + this.next = MotaActionBlocks['restart_s'].xmlText([ + this.next]); + break; case "function": var func = data["function"]; func=func.split('{').slice(1).join('{').split('}').slice(0,-1).join('}').trim().split('\n').join('\\n'); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 90bf5962..ee3b9550 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -68,6 +68,7 @@ editor_blockly = function () { MotaActionBlocks['tip_s'].xmlText(), MotaActionBlocks['win_s'].xmlText(), MotaActionBlocks['lose_s'].xmlText(), + MotaActionBlocks['restart_s'].xmlText(), MotaActionBlocks['confirm_s'].xmlText(), MotaActionBlocks['choices_s'].xmlText([ '选择剑或者盾','流浪者','man',MotaActionBlocks['choicesContext'].xmlText([ @@ -99,16 +100,27 @@ editor_blockly = function () { MotaActionBlocks['changePos_0_s'].xmlText(), MotaActionBlocks['changePos_1_s'].xmlText(), MotaActionBlocks['battle_s'].xmlText(), - MotaActionBlocks['openDoor_s'].xmlText(), - MotaActionBlocks['closeDoor_s'].xmlText(), MotaActionBlocks['useItem_s'].xmlText(), MotaActionBlocks['openShop_s'].xmlText(), - MotaActionBlocks['setBlock_s'].xmlText(), - MotaActionBlocks['setBgFgBlock_s'].xmlText(), + MotaActionBlocks['disableShop_s'].xmlText(), MotaActionBlocks['setHeroIcon_s'].xmlText(), MotaActionBlocks['follow_s'].xmlText(), MotaActionBlocks['unfollow_s'].xmlText(), ], + '地图处理':[ + MotaActionBlocks['openDoor_s'].xmlText(), + MotaActionBlocks['closeDoor_s'].xmlText(), + MotaActionBlocks['show_s'].xmlText(), + MotaActionBlocks['hide_s'].xmlText(), + MotaActionBlocks['setBlock_s'].xmlText(), + MotaActionBlocks['move_s'].xmlText(), + MotaActionBlocks['jump_s'].xmlText(), + MotaActionBlocks['showBgFgMap_s'].xmlText(), + MotaActionBlocks['hideBgFgMap_s'].xmlText(), + MotaActionBlocks['setBgFgBlock_s'].xmlText(), + MotaActionBlocks['showFloorImg_s'].xmlText(), + MotaActionBlocks['hideFloorImg_s'].xmlText(), + ], '事件控制':[ MotaActionBlocks['if_s'].xmlText(), MotaActionBlocks['if_1_s'].xmlText(), @@ -123,18 +135,9 @@ editor_blockly = function () { MotaActionBlocks['continue_s'].xmlText(), MotaActionBlocks['revisit_s'].xmlText(), MotaActionBlocks['exit_s'].xmlText(), - MotaActionBlocks['show_s'].xmlText(), - MotaActionBlocks['hide_s'].xmlText(), - MotaActionBlocks['showFloorImg_s'].xmlText(), - MotaActionBlocks['hideFloorImg_s'].xmlText(), - MotaActionBlocks['showBgFgMap_s'].xmlText(), - MotaActionBlocks['hideBgFgMap_s'].xmlText(), MotaActionBlocks['trigger_s'].xmlText(), MotaActionBlocks['insert_1_s'].xmlText(), MotaActionBlocks['insert_2_s'].xmlText(), - MotaActionBlocks['move_s'].xmlText(), - MotaActionBlocks['jump_s'].xmlText(), - MotaActionBlocks['disableShop_s'].xmlText(), ], '特效/声音':[ MotaActionBlocks['sleep_s'].xmlText(), diff --git a/libs/events.js b/libs/events.js index 07ede640..7adeffb3 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1448,6 +1448,10 @@ events.prototype._action_lose = function (data, x, y, prefix) { this.lose(data.reason); } +events.prototype._action_restart = function (data, x, y, prefix) { + core.restart(); +} + events.prototype._action_function = function (data, x, y, prefix) { var func = data["function"]; try {