setBlock for id

This commit is contained in:
oc 2019-04-08 01:33:03 +08:00
parent c5cc4aebe1
commit 29e9edae0e
3 changed files with 17 additions and 7 deletions

View File

@ -657,6 +657,7 @@ revisit常常使用在一些商人之类的地方当用户购买物品后不
{"type": "setBlock", "floorId": "MT1", "loc": [3,3], "number": 233}, // 将MT1层的(3,3)点变成数字233
{"type": "setBlock", "loc": [2,1], "number": 121}, // 省略floorId则默认为本层
{"type": "setBlock", "number": 57}, // loc也可省略默认为当前点
{"type": "setBlock", "number": "yellowDoor"}, // 从V2.6开始也允许写图块ID
]
```
@ -666,6 +667,8 @@ loc为可选的表示要更改地图块的坐标。如果忽略此项
number为**要更改到的数字**,有关“数字”的定义详见参见[素材的机制](personalization#素材的机制)。
从V2.6开始number也允许写图块的ID将自动转成对应的数字。
图块更改后:
- 其启用/禁用状态不会发生任何改变。原来是启用还是启用,原来是禁用还是禁用。

View File

@ -728,20 +728,20 @@ return code;
*/;
setBlock_s
: '转变图块为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
: '转变图块为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
/* 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
default : [0,"","",""]
default : ["yellowDoor","","",""]
var floorstr = '';
if (PosString_0 && PosString_1) {
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
}
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var code = '{"type": "setBlock", "number":'+Int_0+floorstr+IdString_0+'},\n';
var code = '{"type": "setBlock", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n';
return code;
*/;
@ -870,20 +870,20 @@ return code;
*/;
setBgFgBlock_s
: '转变图层块' Bg_Fg_List '为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
: '转变图层块' Bg_Fg_List '为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
/* 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
default : ["bg",0,"","",""]
default : ["bg","yellowDoor","","",""]
var floorstr = '';
if (PosString_0 && PosString_1) {
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
}
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number":'+Int_0+floorstr+IdString_0+'},\n';
var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n';
return code;
*/;

View File

@ -1425,7 +1425,10 @@ maps.prototype.setBlock = function (number, x, y, floorId) {
floorId = floorId || core.status.floorId;
if (!floorId || number == null || x == null || y == null) return;
if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return;
if (typeof number == 'string') number = core.getNumberById(number);
if (typeof number == 'string') {
if (/^\d+$/.test(number)) number = parseInt(number);
else number = core.getNumberById(number);
}
var originBlock = core.getBlock(x, y, floorId, true);
var block = this.initBlock(x, y, number, true, core.floors[floorId]);
@ -1479,6 +1482,10 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) {
if (!floorId || number == null || x == null || y == null) return;
if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return;
if (name != 'bg' && name != 'fg') return;
if (typeof number == 'string') {
if (/^\d+$/.test(number)) number = parseInt(number);
else number = core.getNumberById(number);
}
var vFlag = "__" + name + "Value__" + floorId + "_" + x + "_" + y;
core.setFlag(vFlag, number);