From 755919307d14eb26215e898aecdf33f1d4823a32 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Wed, 31 Oct 2018 17:34:41 +0800 Subject: [PATCH] Event: Comment --- _server/blockly/MotaAction.g4 | 18 ++++++++++++++++++ _server/editor_blockly.js | 1 + docs/event.md | 12 ++++++++++++ libs/events.js | 3 +++ 4 files changed, 34 insertions(+) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 892bd536..f877be0f 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -182,6 +182,7 @@ return code; action : text_0_s | text_1_s + | comment_s | autoText_s | setText_s | tip_s @@ -282,6 +283,19 @@ var code = '"'+title+EvalString_1+EvalString_2+'",\n'; return code; */; +comment_s + : '添加注释' ':' EvalString Newline + + +/* comment_s +tooltip : text:显示一段文字(剧情) +helpUrl : https://ckcz123.github.io/mota-js/#/event?id=comment%ef%bc%9a%e6%b7%bb%e5%8a%a0%e6%b3%a8%e9%87%8a +default : ["可以在这里写添加任何注释内容"] +colour : this.commentColor +var code = '{"type": "comment", "text": "'+EvalString_0+'"},\n'; +return code; +*/; + autoText_s : '自动剧情文本: 标题' EvalString? '图像' IdString? '对话框效果' EvalString? '时间' Int BGNL? EvalString Newline @@ -1575,6 +1589,7 @@ this.evisitor.printColor=70; this.evisitor.dataColor=130; this.evisitor.eventColor=220; this.evisitor.soundColor=20; +this.evisitor.commentColor=285; */ /* Function_1 @@ -1704,6 +1719,9 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['autoText_s'].xmlText([ '','','',data.time,this.EvalString(data.text),this.next]); break; + case "comment": // 注释 + this.next = MotaActionBlocks['comment_s'].xmlText([data.text,this.next]); + break; case "setText": // 设置剧情文本的属性 var setTextfunc = function(a){return a?JSON.stringify(a).slice(1,-1):null;} data.title=setTextfunc(data.title); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 4a12dd87..8ac1ee48 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -56,6 +56,7 @@ editor_blockly = function () { '显示文字':[ MotaActionBlocks['text_0_s'].xmlText(), MotaActionBlocks['text_1_s'].xmlText(), + MotaActionBlocks['comment_s'].xmlText(), MotaActionFunctions.actionParser.parseList({"type": "choices", "text": "是否跳过剧情", "choices": [ {"text": "是", "action": []}, {"text": "否", "action": [ diff --git a/docs/event.md b/docs/event.md index d0418e49..61521133 100644 --- a/docs/event.md +++ b/docs/event.md @@ -327,6 +327,18 @@ time为可选项,表示文字添加的速度。若此项设置为0将直接全 值得注意的是,提示的text内容也是可以使用`${ }`来计算表达式的值的。 +### comment:添加注释 + +使用`{"type": "comment"}`可以添加一段注释 + +``` js +"x,y": [ // 实际执行的事件列表 + {"type": "comment", "text": "这是一段会被跳过的注释内容"} +] +``` + +这个事件将在运行时被游戏跳过。 + ### setValue:设置勇士的某个属性、道具个数,或某个变量/Flag的值 `{"type": "setValue"}` 能修改勇士的某个属性、道具个数、或某个自定义变量或`Flag`的值。 diff --git a/libs/events.js b/libs/events.js index bc56158e..14ac2254 100644 --- a/libs/events.js +++ b/libs/events.js @@ -392,6 +392,9 @@ events.prototype.doAction = function() { }, data.time || 3000); } break; + case "comment": + this.doAction(); + break; case "setText": // 设置文本状态 ["position", "offset", "bold", "titlefont", "textfont", "time"].forEach(function (t) { if (core.isset(data[t])) core.status.textAttribute[t]=data[t];