Merge branch 'v2.0' of https://github.com/ckcz123/mota-js into v2.0

This commit is contained in:
oc 2019-03-30 23:29:47 +08:00
commit 31facb29e4
6 changed files with 93 additions and 39 deletions

View File

@ -682,12 +682,6 @@ revisit常常使用在一些商人之类的地方当用户购买物品后不
]
```
### addToList将本公共事件插入到快捷列表中
使用 `{"type": "addToList"}` 可以将当前公共事件插入到快捷商店列表中。
此项只能在公共事件中被执行。详见[公共事件](personalization#公共事件)。
### setBlock设置某个图块
我们可以采用 `{"type": "setBlock"}` 来改变某个地图块。

View File

@ -65,6 +65,7 @@ return code;
shoplist
: shopsub
| shopcommonevent
| emptyshop
;
@ -77,6 +78,24 @@ var code = ' \n';
return code;
*/;
shopcommonevent
: '商店 id' IdString '快捷商店栏中名称' EvalString BGNL? '未开启状态则不显示在列表中' Bool BGNL? '执行的公共事件 id' EvalString '参数列表' EvalString?
/* shopcommonevent
tooltip : 全局商店, 执行一个公共事件
helpUrl : https://h5mota.com/games/template/docs/#/
default : ["shop1","回收钥匙商店",false,"回收钥匙商店",""]
var code = {
'id': IdString_0,
'textInList': EvalString_0,
'mustEnable': Bool_0,
'commonEvent': EvalString_1,
'args': EvalString_2
}
code=JSON.stringify(code,null,2)+',\n';
return code;
*/;
shopsub
: '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' Bool BGNL? Newline '未开启状态则不显示在列表中' Bool BGNL? NewLine '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND
@ -240,7 +259,6 @@ action
| insert_2_s
| revisit_s
| exit_s
| addToList_s
| setBlock_s
| showFloorImg_s
| hideFloorImg_s
@ -304,6 +322,7 @@ action
| callBook_s
| callSave_s
| callLoad_s
| unknow_s
| function_s
| pass_s
;
@ -694,18 +713,6 @@ var code = '{"type": "exit"},\n';
return code;
*/;
addToList_s
: '将本公共事件插入到快捷列表中' Newline
/* addToList_s
tooltip : addToList: 将本公共事件插入到快捷列表中
helpUrl : https://h5mota.com/games/template/docs/#/event?id=exit%EF%BC%9A%E7%AB%8B%E5%88%BB%E7%BB%93%E6%9D%9F%E5%BD%93%E5%89%8D%E4%BA%8B%E4%BB%B6
colour : this.eventColor
var code = '{"type": "addToList"},\n';
return code;
*/;
setBlock_s
: '转变图块为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
@ -1739,6 +1746,19 @@ var code = '{"type": "callLoad"},\n';
return code;
*/;
unknow_s
: '自定义事件' BGNL? RawEvalString
/* unknow_s
tooltip : 通过脚本自定义的事件类型, 以及编辑器不识别的事件类型
helpUrl : https://h5mota.com/games/template/docs/#/
default : ['{"type":"eventType1"}']
colour : this.dataColor
var tempobj={};
eval("tempobj='"+RawEvalString_0+"'");
var code = tempobj +',\n';
return code;
*/;
function_s
: '自定义JS脚本' '不自动执行下一个事件' Bool BGNL? Newline RawEvalString Newline BEND Newline
@ -2127,10 +2147,21 @@ ActionParser.prototype.parse = function (obj,type) {
obj.id,obj.name,obj.icon,obj.textInList,obj.commonTimes,obj.mustEnable,obj.use,obj.need,parser.EvalString(obj.text),text_choices,next
]);
}
var buildcommentevent = function(obj,parser,next){
return MotaActionBlocks['shopcommonevent'].xmlText([
obj.id,parser.EvalString(obj.textInList),obj.mustEnable,parser.EvalString(obj.commonEvent),parser.EvalString(obj.args),next
]);
}
var next=null;
if(!obj)obj=[];
while(obj.length){
next=buildsub(obj.pop(),this,next);
var shopobj=obj.pop()
if(shopobj.choices)
next=buildsub(shopobj,this,next);
else if(shopobj.commonEvent)
next=buildcommentevent(shopobj,this,next);
else
throw new Error("[警告]出错啦!\n"+shopobj.id+" 无效的商店");
}
return MotaActionBlocks['shop_m'].xmlText([next]);
@ -2617,14 +2648,16 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['exit_s'].xmlText([
this.next]);
break;
case "addToList": // 立刻结束事件
this.next = MotaActionBlocks['addToList_s'].xmlText([
this.next]);
break;
case "animateImage": // 兼容 animateImage
break;
default:
throw new Error("[警告]出错啦!\n"+data.type+" 事件不被支持...");
var rawdata = JSON.stringify(data,function(k,v){
if(typeof(v)=='string')return v.split('\n').join('\\n');
else return v;
},2);
rawdata=rawdata.split('\n').join('\\n');
this.next = MotaActionBlocks['unknow_s'].xmlText([
rawdata,this.next]);
}
this.parseAction();
return;

View File

@ -660,12 +660,6 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
"_bool": "bool",
"_data": "是否在经过领域/夹击/路障等伤害后禁用快捷商店。"
},
"quickCommonEvents": {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "是否使用自定义的公共事件列表来代替快捷商店列表。\n如果此项开启则快捷商店列表中将会显示加入的公共事件。"
},
"checkConsole": {
"_leaf": true,
"_type": "checkbox",

View File

@ -37,6 +37,11 @@ editor_blockly = function () {
{"text": "防御+4", "effect": "status:def+=4"},
{"text": "魔防+10", "effect": "status:mdef+=10"}
]
},{
"id": "keyShop1",
"textInList": "回收钥匙商店",
"commonEvent": "回收钥匙商店",
"args": ""
}],'shop'),
MotaActionBlocks['afterBattle_m'].xmlText(),
MotaActionBlocks['afterGetItem_m'].xmlText(),
@ -123,7 +128,6 @@ editor_blockly = function () {
MotaActionBlocks['hideBgFgMap_s'].xmlText(),
MotaActionBlocks['trigger_s'].xmlText(),
MotaActionBlocks['insert_1_s'].xmlText(),
MotaActionBlocks['addToList_s'].xmlText(),
MotaActionBlocks['insert_2_s'].xmlText(),
MotaActionBlocks['move_s'].xmlText(),
MotaActionBlocks['jump_s'].xmlText(),
@ -584,6 +588,7 @@ function omitedcheckUpdateFunction(event) {
'showTextImage_s': 'EvalString_0',
'function_s': 'RawEvalString_0',
'shopsub': 'EvalString_3',
'unknow_s': 'RawEvalString_0',
}
var f = b ? textStringDict[b.type] : null;
if (f) {

View File

@ -249,6 +249,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"name": "贪婪之神",
"icon": "blueShop",
"textInList": "1F金币商店",
"commonTimes": false,
"mustEnable": false,
"use": "money",
"need": "20+10*times*(times+1)",
"text": "勇敢的武士啊,给我${need}金币就可以:",
@ -276,6 +278,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"name": "经验之神",
"icon": "pinkShop",
"textInList": "1F经验商店",
"commonTimes": false,
"mustEnable": false,
"use": "experience",
"need": "-1",
"text": "勇敢的武士啊,给我若干经验就可以:",
@ -296,6 +300,13 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"effect": "status:def+=5"
}
]
},
{
"id": "keyShop1",
"textInList": "1F回收钥匙商店",
"mustEnable": false,
"commonEvent": "回收钥匙商店",
"args": ""
}
],
"levelUp": [

View File

@ -241,18 +241,15 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
"回收钥匙商店": [
{
"type": "comment",
"text": "公共事件:回收钥匙商店"
},
{
"type": "addToList"
"text": "此事件在全局商店中被引用了(全局商店keyShop1)"
},
{
"type": "comment",
"text": "使用上述事件并在全塔属性打开quickCommonEvent开关"
"text": "解除引用前勿删除此事件"
},
{
"type": "comment",
"text": "就可以在快捷列表V键使用本公共事件"
"text": "玩家在快捷列表V键中可以使用本公共事件"
},
{
"type": "while",
@ -300,7 +297,27 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
255,
1
],
"action": []
"action": [
{
"type": "if",
"condition": "item:blueKey >= 1",
"true": [
{
"type": "addValue",
"name": "item:blueKey",
"value": "-1"
},
{
"type": "addValue",
"name": "status:money",
"value": "50"
}
],
"false": [
"\t[商人,woman]你没有蓝钥匙!"
]
}
]
},
{
"text": "离开",