type:insert
This commit is contained in:
parent
190b2d586b
commit
7e7d5dd563
@ -192,6 +192,7 @@ action
|
|||||||
| show_s
|
| show_s
|
||||||
| hide_s
|
| hide_s
|
||||||
| trigger_s
|
| trigger_s
|
||||||
|
| insert_s
|
||||||
| revisit_s
|
| revisit_s
|
||||||
| exit_s
|
| exit_s
|
||||||
| setBlock_s
|
| setBlock_s
|
||||||
@ -481,6 +482,20 @@ var code = '{"type": "trigger", "loc": ['+PosString_0+','+PosString_1+']},\n';
|
|||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
|
insert_s
|
||||||
|
: '插入事件' 'x' PosString ',' 'y' PosString '楼层' IdString? Newline
|
||||||
|
|
||||||
|
|
||||||
|
/* insert_s
|
||||||
|
tooltip : insert: 立即插入另一个地点的事件执行,当前事件不会中断,事件坐标不会改变
|
||||||
|
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6
|
||||||
|
default : ["0","0",""]
|
||||||
|
colour : this.eventColor
|
||||||
|
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
|
||||||
|
var code = '{"type": "insert", "loc": ['+PosString_0+','+PosString_1+']'+IdString_0+'},\n';
|
||||||
|
return code;
|
||||||
|
*/;
|
||||||
|
|
||||||
revisit_s
|
revisit_s
|
||||||
: '重启当前事件' Newline
|
: '重启当前事件' Newline
|
||||||
|
|
||||||
@ -1966,6 +1981,10 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
this.next = MotaActionBlocks['trigger_s'].xmlText([
|
this.next = MotaActionBlocks['trigger_s'].xmlText([
|
||||||
data.loc[0],data.loc[1],this.next]);
|
data.loc[0],data.loc[1],this.next]);
|
||||||
break;
|
break;
|
||||||
|
case "insert": // 强制插入另一个点的事件在当前事件列表执行,当前坐标和楼层不会改变
|
||||||
|
this.next = MotaActionBlocks['insert_s'].xmlText([
|
||||||
|
data.loc[0],data.loc[1],data.floorId||'',this.next]);
|
||||||
|
break;
|
||||||
case "playSound":
|
case "playSound":
|
||||||
this.next = MotaActionBlocks['playSound_s'].xmlText([
|
this.next = MotaActionBlocks['playSound_s'].xmlText([
|
||||||
data.name,this.next]);
|
data.name,this.next]);
|
||||||
|
|||||||
@ -126,6 +126,7 @@ editor_blockly = function () {
|
|||||||
MotaActionBlocks['hideBgFgMap_s'].xmlText(),
|
MotaActionBlocks['hideBgFgMap_s'].xmlText(),
|
||||||
MotaActionBlocks['setBgFgBlock_s'].xmlText(),
|
MotaActionBlocks['setBgFgBlock_s'].xmlText(),
|
||||||
MotaActionBlocks['trigger_s'].xmlText(),
|
MotaActionBlocks['trigger_s'].xmlText(),
|
||||||
|
MotaActionBlocks['insert_s'].xmlText(),
|
||||||
MotaActionBlocks['move_s'].xmlText(),
|
MotaActionBlocks['move_s'].xmlText(),
|
||||||
MotaActionBlocks['jump_s'].xmlText(),
|
MotaActionBlocks['jump_s'].xmlText(),
|
||||||
MotaActionBlocks['disableShop_s'].xmlText(),
|
MotaActionBlocks['disableShop_s'].xmlText(),
|
||||||
|
|||||||
@ -477,6 +477,32 @@ NPC对话事件结束后如果需要NPC消失也需要调用 `{"type": "hide"}`
|
|||||||
|
|
||||||
例如上面这个例子,下面的文字将不会再被显示,而是直接跳转到`"3,6"`对应的事件列表从头执行。
|
例如上面这个例子,下面的文字将不会再被显示,而是直接跳转到`"3,6"`对应的事件列表从头执行。
|
||||||
|
|
||||||
|
### insert:插入另一个地点的事件
|
||||||
|
|
||||||
|
`{"type":"insert"}` 会插入另一个地点的事件执行。
|
||||||
|
|
||||||
|
其基本写法如下:
|
||||||
|
|
||||||
|
``` js
|
||||||
|
"x,y": [ // 实际执行的事件列表
|
||||||
|
{"type": "insert", "loc": [3,6]}, // 插入[3,6]点的事件并执行
|
||||||
|
{"type": "insert", "loc": [10,10], "floorId": "MT1"}, // 插入MT1层[10,10]点的事件并执行
|
||||||
|
"上面的插入事件执行完毕后会接着继续执行后面的事件"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
loc是必须的,代表另一个地点的坐标。
|
||||||
|
|
||||||
|
floorId可选,代表另一个地点所在的楼层;如果不写则默认为当前层。
|
||||||
|
|
||||||
|
和`type:trigger`不同的是,**`type:trigger`是立刻将当前事件结束(剩下所有内容都忽略),然后重新启动另一个地点的action事件。**
|
||||||
|
|
||||||
|
但是`type:insert`不会结束当前事件,而是直接将另一个地点的事件列表“插入”到当前事件列表中执行。
|
||||||
|
|
||||||
|
**这个过程中,当前事件不会被结束,当前的楼层和事件坐标不会发生改变。** 插入的事件执行完毕后,会继续执行接下来的内容。
|
||||||
|
|
||||||
|
我们某个事件写在某个角落的墙上然后远程调用,从而达到“公共事件”的效果。
|
||||||
|
|
||||||
### revisit:立即重启当前事件
|
### revisit:立即重启当前事件
|
||||||
|
|
||||||
revisit和trigger完全相同,只不过是立刻触发的还是本地点的事件
|
revisit和trigger完全相同,只不过是立刻触发的还是本地点的事件
|
||||||
|
|||||||
@ -521,6 +521,15 @@ case 89: // 使用该按键的keyCode,比如Y键就是89
|
|||||||
|
|
||||||
## 公共事件
|
## 公共事件
|
||||||
|
|
||||||
|
从2.5.1开始,H5提供了`{"type":"insert"}`事件,完美支持了公共事件的写法。
|
||||||
|
|
||||||
|
我们只需要将需要的公共事件放在某个角落的墙上(或者甚至单独弄一层专门摆放公共事件),并使用“插入事件”,即可进行调用。
|
||||||
|
|
||||||
|
具体详见[插入另一个地点的事件](event#insert:插入另一个地点的事件)。
|
||||||
|
|
||||||
|
当然,继续使用**插件**的写法也是可以的。具体参见“脚本编辑 - 插件编写”。
|
||||||
|
|
||||||
|
<!--
|
||||||
在RM中,存在公共事件的说法;也就是通过某个指令来调用一系列事件的触发。
|
在RM中,存在公共事件的说法;也就是通过某个指令来调用一系列事件的触发。
|
||||||
|
|
||||||
在H5中,我们可以使用“插件”的形式来达成这个效果。具体参见“脚本编辑 - 插件编写”。
|
在H5中,我们可以使用“插件”的形式来达成这个效果。具体参见“脚本编辑 - 插件编写”。
|
||||||
@ -547,7 +556,7 @@ this.myfunc = function(x) {
|
|||||||
然后比如我们在某个道具的使用效果 `useItemEffect` 中写 `core.plugin.myfunc(2)` 即可调用此公共事件(插件)。也可以在战后事件或自定义脚本等位置来写。
|
然后比如我们在某个道具的使用效果 `useItemEffect` 中写 `core.plugin.myfunc(2)` 即可调用此公共事件(插件)。也可以在战后事件或自定义脚本等位置来写。
|
||||||
|
|
||||||
通过这种,将脚本和自定义事件混用的方式,可以达到和RM中公共事件类似的效果,即一个调用触发一系列事件。
|
通过这种,将脚本和自定义事件混用的方式,可以达到和RM中公共事件类似的效果,即一个调用触发一系列事件。
|
||||||
|
-->
|
||||||
## 自定义状态栏(新增显示项)
|
## 自定义状态栏(新增显示项)
|
||||||
|
|
||||||
在V2.2以后,我们可以自定义状态栏背景图(全塔属性 - statusLeftBackground)等等。
|
在V2.2以后,我们可以自定义状态栏背景图(全塔属性 - statusLeftBackground)等等。
|
||||||
|
|||||||
@ -148,7 +148,7 @@ function core() {
|
|||||||
},
|
},
|
||||||
'textAttribute': {
|
'textAttribute': {
|
||||||
'position': "center",
|
'position': "center",
|
||||||
"offset": 20,
|
"offset": 0,
|
||||||
"title": [255,215,0,1],
|
"title": [255,215,0,1],
|
||||||
"background": [0,0,0,0.85],
|
"background": [0,0,0,0.85],
|
||||||
"text": [255,255,255,1],
|
"text": [255,255,255,1],
|
||||||
|
|||||||
@ -774,6 +774,15 @@ events.prototype.doAction = function() {
|
|||||||
this.doAction();
|
this.doAction();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "insert":
|
||||||
|
{
|
||||||
|
var toX=core.calValue(data.loc[0]), toY=core.calValue(data.loc[1]);
|
||||||
|
var floorId = data.floorId || core.status.floorId;
|
||||||
|
var event = core.floors[floorId].events[toX+","+toY];
|
||||||
|
if (core.isset(event)) core.insertAction(event);
|
||||||
|
this.doAction();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "playSound":
|
case "playSound":
|
||||||
if (!core.status.replay.replaying)
|
if (!core.status.replay.replaying)
|
||||||
core.playSound(data.name);
|
core.playSound(data.name);
|
||||||
@ -910,7 +919,7 @@ events.prototype.doAction = function() {
|
|||||||
case "switch": // 条件选择
|
case "switch": // 条件选择
|
||||||
var key = core.calValue(data.condition)
|
var key = core.calValue(data.condition)
|
||||||
for (var i = 0; i < data.caseList.length; i++) {
|
for (var i = 0; i < data.caseList.length; i++) {
|
||||||
if (core.calValue(data.caseList[i].case) == key || core.calValue(data.caseList[i].case) == "default") {
|
if (data.caseList[i].case=="default" || core.calValue(data.caseList[i].case) == key) {
|
||||||
core.events.insertAction(data.caseList[i].action);
|
core.events.insertAction(data.caseList[i].action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -594,7 +594,7 @@ main.floors.sample1=
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"case": "'default'",
|
"case": "default",
|
||||||
"action": [
|
"action": [
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user