diff --git a/_docs/event.md b/_docs/event.md index 866a771c..b4daf8e6 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -1400,6 +1400,10 @@ async可选,如果为true则会异步执行(即不等待当前事件执行 在玩家进行一次存档,或者直接点返回游戏后,将接着执行后面的事件。录像播放将会跳过本事件。 +### autoSave:自动存档 + +`{"type": "autoSave"}` 可以立刻进行一次自动存档。录像播放不会跳过本事件。 + ### callLoad:呼出读档界面 `{"type": "callLoad"}` 可以呼出读档页面并允许玩家进行读档。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 6906166b..4a69e318 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -338,6 +338,7 @@ action | confirm_s | callBook_s | callSave_s + | autoSave_s | callLoad_s | unknown_s | function_s @@ -1799,7 +1800,7 @@ callSave_s /* callSave_s -tooltip : callSave: 呼出存档页面;之后读此档将执行eachArrive +tooltip : callSave: 呼出存档页面 helpUrl : https://h5mota.com/games/template/docs/#/event?id=callSave%ef%bc%9a%e5%91%bc%e5%87%ba%e5%ad%98%e6%a1%a3%e7%95%8c%e9%9d%a2 colour : this.soundColor var code = '{"type": "callSave"},\n'; @@ -1807,6 +1808,19 @@ return code; */; +autoSave_s + : '自动存档' + + +/* autoSave_s +tooltip : autoSave: 自动存档 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=autoSave%ef%bc%9a%e8%87%aa%e5%8a%a8%e5%ad%98%e6%a1%a3 +colour : this.soundColor +var code = '{"type": "autoSave"},\n'; +return code; +*/; + + callLoad_s : '呼出读档页面' @@ -2750,6 +2764,10 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['callSave_s'].xmlText([ this.next]); break; + case "autoSave": // 自动存档 + this.next = MotaActionBlocks['autoSave_s'].xmlText([ + this.next]); + break; case "callLoad": // 呼出读档界面 this.next = MotaActionBlocks['callLoad_s'].xmlText([ this.next]); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index ee3b9550..ba2f16e5 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -161,6 +161,7 @@ editor_blockly = function () { MotaActionBlocks['setVolume_s'].xmlText(), MotaActionBlocks['callBook_s'].xmlText(), MotaActionBlocks['callSave_s'].xmlText(), + MotaActionBlocks['autoSave_s'].xmlText(), MotaActionBlocks['callLoad_s'].xmlText(), ], '原生脚本':[ diff --git a/libs/control.js b/libs/control.js index 4288890f..1871249e 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1480,14 +1480,28 @@ control.prototype._replayAction_key = function (action) { ////// 自动存档 ////// control.prototype.autosave = function (removeLast) { - if (core.status.event.id!=null) return; + var inEvent = false; // 检测是否是事件中的自动存档 + if (core.status.event.id!=null) { + if (core.status.event.id!='action') return; + inEvent = true; + } var x=null; if (removeLast) x=core.status.route.pop(); - core.status.route.push("turn:"+core.getHeroLoc('direction')); + if (inEvent) { + core.setFlag("__events__", core.clone(core.status.event.data)); + } + else { + core.status.route.push("turn:"+core.getHeroLoc('direction')); + } core.saves.autosave.data = core.saveData(); core.saves.autosave.updated = true; core.saves.ids[0] = true; - core.status.route.pop(); + if (inEvent) { + core.removeFlag("__events__"); + } + else { + core.status.route.pop(); + } if (x) core.status.route.push(x); } diff --git a/libs/events.js b/libs/events.js index 7adeffb3..5e372958 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1579,6 +1579,12 @@ events.prototype._action_callSave = function (data, x, y, prefix) { } } +events.prototype._action_autoSave = function (data, x, y, prefix) { + core.autosave(); + core.drawTip("已自动存档"); + core.doAction(); +} + events.prototype._action_callLoad = function (data, x, y, prefix) { if (this.__action_checkReplaying()) return; var e = core.clone(core.status.event.data);