blockly中支持show hide多事件以及type:input
This commit is contained in:
parent
f1d603e9e6
commit
89bd795cf0
@ -187,6 +187,7 @@ action
|
|||||||
| win_s
|
| win_s
|
||||||
| lose_s
|
| lose_s
|
||||||
| if_s
|
| if_s
|
||||||
|
| input_s
|
||||||
| choices_s
|
| choices_s
|
||||||
| function_s
|
| function_s
|
||||||
| pass_s
|
| pass_s
|
||||||
@ -279,17 +280,23 @@ return code;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
show_s
|
show_s
|
||||||
: '显示事件' 'x' Int ',' 'y' Int '楼层' IdString? '动画时间' Int? Newline
|
: '显示事件' 'x' EvalString ',' 'y' EvalString '楼层' IdString? '动画时间' Int? Newline
|
||||||
;
|
;
|
||||||
|
|
||||||
/* show_s
|
/* show_s
|
||||||
tooltip : show: 将一个禁用事件启用,楼层和动画时间可不填
|
tooltip : show: 将禁用事件启用,楼层和动画时间可不填,xy可用逗号分隔表示多个点
|
||||||
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=show-%e5%b0%86%e4%b8%80%e4%b8%aa%e7%a6%81%e7%94%a8%e4%ba%8b%e4%bb%b6%e5%90%af%e7%94%a8
|
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=show-%e5%b0%86%e4%b8%80%e4%b8%aa%e7%a6%81%e7%94%a8%e4%ba%8b%e4%bb%b6%e5%90%af%e7%94%a8
|
||||||
default : [0,0,"",500]
|
default : [0,0,"",500]
|
||||||
colour : this.eventColor
|
colour : this.eventColor
|
||||||
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
|
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
|
||||||
Int_2 = Int_2 ?(', "time": '+Int_2):'';
|
var pattern = /^(\d|1[0-2])(,\d|1[0-2])*$/;
|
||||||
var code = '{"type": "show", "loc": ['+Int_0+','+Int_1+']'+IdString_0+''+Int_2+'},\n';
|
if(!pattern.test(EvalString_0) || !pattern.test(EvalString_1))throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||||
|
EvalString_0=EvalString_0.split(',');
|
||||||
|
EvalString_1=EvalString_1.split(',');
|
||||||
|
if(EvalString_0.length!==EvalString_1.length)throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||||
|
for(var ii=0;ii<EvalString_0.length;ii++)EvalString_0[ii]='['+EvalString_0[ii]+','+EvalString_1[ii]+']';
|
||||||
|
Int_0 = Int_0 ?(', "time": '+Int_0):'';
|
||||||
|
var code = '{"type": "show", "loc": ['+EvalString_0.join(',')+']'+IdString_0+''+Int_0+'},\n';
|
||||||
return code;
|
return code;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -298,13 +305,19 @@ hide_s
|
|||||||
;
|
;
|
||||||
|
|
||||||
/* hide_s
|
/* hide_s
|
||||||
tooltip : hide: 将一个启用事件禁用,所有参数均可不填,代表禁用事件自身
|
tooltip : hide: 将一个启用事件禁用,所有参数均可不填,代表禁用事件自身,xy可用逗号分隔表示多个点
|
||||||
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=hide-%e5%b0%86%e4%b8%80%e4%b8%aa%e5%90%af%e7%94%a8%e4%ba%8b%e4%bb%b6%e7%a6%81%e7%94%a8
|
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=hide-%e5%b0%86%e4%b8%80%e4%b8%aa%e5%90%af%e7%94%a8%e4%ba%8b%e4%bb%b6%e7%a6%81%e7%94%a8
|
||||||
default : ["","","",500]
|
default : ["","","",500]
|
||||||
colour : this.eventColor
|
colour : this.eventColor
|
||||||
var floorstr = '';
|
var floorstr = '';
|
||||||
if (EvalString_0 && EvalString_1) {
|
if (EvalString_0 && EvalString_1) {
|
||||||
floorstr = ', "loc": ['+EvalString_0+','+EvalString_1+']';
|
var pattern = /^(\d|1[0-2])(,\d|1[0-2])*$/;
|
||||||
|
if(!pattern.test(EvalString_0) || !pattern.test(EvalString_1))throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||||
|
EvalString_0=EvalString_0.split(',');
|
||||||
|
EvalString_1=EvalString_1.split(',');
|
||||||
|
if(EvalString_0.length!==EvalString_1.length)throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||||
|
for(var ii=0;ii<EvalString_0.length;ii++)EvalString_0[ii]='['+EvalString_0[ii]+','+EvalString_1[ii]+']';
|
||||||
|
floorstr = ', "loc": ['+EvalString_0.join(',')+']';
|
||||||
}
|
}
|
||||||
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
|
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
|
||||||
Int_0 = Int_0 ?(', "time": '+Int_0):'';
|
Int_0 = Int_0 ?(', "time": '+Int_0):'';
|
||||||
@ -690,6 +703,19 @@ var code = '{"type": "lose", "reason": "'+EvalString_0+'"},\n';
|
|||||||
return code;
|
return code;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
input_s
|
||||||
|
: '接受用户输入,提示' ':' EvalString Newline
|
||||||
|
;
|
||||||
|
|
||||||
|
/* input_s
|
||||||
|
tooltip : input:接受用户输入, 事件只能接受非负整数输入, 所有非法的输入将全部变成0
|
||||||
|
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=input%ef%bc%9a%e6%8e%a5%e5%8f%97%e7%94%a8%e6%88%b7%e8%be%93%e5%85%a5
|
||||||
|
default : ["请输入一个数"]
|
||||||
|
colour : this.dataColor
|
||||||
|
var code = '{"type": "input", "text": "'+EvalString_0+'"},\n';
|
||||||
|
return code;
|
||||||
|
*/
|
||||||
|
|
||||||
if_s
|
if_s
|
||||||
: '如果' ':' expression BGNL? Newline action+ '否则' ':' BGNL? Newline action+ BEND Newline
|
: '如果' ':' expression BGNL? Newline action+ '否则' ':' BGNL? Newline action+ BEND Newline
|
||||||
;
|
;
|
||||||
@ -1109,13 +1135,27 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
this.parseAction();
|
this.parseAction();
|
||||||
break;
|
break;
|
||||||
case "show": // 显示
|
case "show": // 显示
|
||||||
|
if (typeof data.loc[0] == 'number' && typeof data.loc[1] == 'number')
|
||||||
|
data.loc = [data.loc];
|
||||||
|
var x_str=[],y_str=[];
|
||||||
|
data.loc.forEach(function (t) {
|
||||||
|
x_str.push(t[0]);
|
||||||
|
y_str.push(t[1]);
|
||||||
|
})
|
||||||
this.next = MotaActionBlocks['show_s'].xmlText([
|
this.next = MotaActionBlocks['show_s'].xmlText([
|
||||||
data.loc[0],data.loc[1],data.floorId||'',data.time||0,this.next]);
|
x_str.join(','),y_str.join(','),data.floorId||'',data.time||0,this.next]);
|
||||||
break;
|
break;
|
||||||
case "hide": // 消失
|
case "hide": // 消失
|
||||||
data.loc=data.loc||[];
|
data.loc=data.loc||[];
|
||||||
|
if (typeof data.loc[0] == 'number' && typeof data.loc[1] == 'number')
|
||||||
|
data.loc = [data.loc];
|
||||||
|
var x_str=[],y_str=[];
|
||||||
|
data.loc.forEach(function (t) {
|
||||||
|
x_str.push(t[0]);
|
||||||
|
y_str.push(t[1]);
|
||||||
|
})
|
||||||
this.next = MotaActionBlocks['hide_s'].xmlText([
|
this.next = MotaActionBlocks['hide_s'].xmlText([
|
||||||
data.loc[0]||'',data.loc[1]||'',data.floorId||'',data.time||0,this.next]);
|
x_str.join(','),y_str.join(','),data.floorId||'',data.time||0,this.next]);
|
||||||
break;
|
break;
|
||||||
case "setBlock": // 设置图块
|
case "setBlock": // 设置图块
|
||||||
data.loc=data.loc||[];
|
data.loc=data.loc||[];
|
||||||
@ -1214,6 +1254,10 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
MotaActionBlocks['evalString_e'].xmlText([data.value]),
|
MotaActionBlocks['evalString_e'].xmlText([data.value]),
|
||||||
this.next]);
|
this.next]);
|
||||||
break;
|
break;
|
||||||
|
case "input":
|
||||||
|
this.next = MotaActionBlocks['input_s'].xmlText([
|
||||||
|
data.text,this.next]);
|
||||||
|
break;
|
||||||
case "if": // 条件判断
|
case "if": // 条件判断
|
||||||
this.next = MotaActionBlocks['if_s'].xmlText([
|
this.next = MotaActionBlocks['if_s'].xmlText([
|
||||||
MotaActionBlocks['evalString_e'].xmlText([data.condition]),
|
MotaActionBlocks['evalString_e'].xmlText([data.condition]),
|
||||||
|
|||||||
@ -70,6 +70,7 @@ initscript=String.raw`
|
|||||||
]),
|
]),
|
||||||
'<label text="数据相关"></label>',
|
'<label text="数据相关"></label>',
|
||||||
MotaActionBlocks['setValue_s'].xmlText(),
|
MotaActionBlocks['setValue_s'].xmlText(),
|
||||||
|
MotaActionBlocks['input_s'].xmlText(),
|
||||||
MotaActionBlocks['update_s'].xmlText(),
|
MotaActionBlocks['update_s'].xmlText(),
|
||||||
MotaActionBlocks['moveHero_s'].xmlText(),
|
MotaActionBlocks['moveHero_s'].xmlText(),
|
||||||
MotaActionBlocks['changeFloor_s'].xmlText(),
|
MotaActionBlocks['changeFloor_s'].xmlText(),
|
||||||
@ -154,12 +155,7 @@ initscript=String.raw`
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},'event'),
|
},'event'),
|
||||||
'<label text="获取用户输入的字符串"></label>',
|
|
||||||
MotaActionFunctions.actionParser.parseList([
|
|
||||||
{"type": "setValue", "name": "flag:inputMsg", "value": "请输入密码"},
|
|
||||||
{"type": "function", "function": "function(){core.setFlag('input',prompt(core.getFlag('inputMsg','请输入字符串'),'xxx')||'')}"},
|
|
||||||
{"type": "if", "condition": 'flag:input == "123456"',"true": [],"false": []},
|
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
var toolboxgap = '<sep gap="5"></sep>'
|
var toolboxgap = '<sep gap="5"></sep>'
|
||||||
|
|||||||
@ -18,13 +18,16 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
|||||||
'def': '防御力',
|
'def': '防御力',
|
||||||
'money': '金币',
|
'money': '金币',
|
||||||
'experience': '经验',
|
'experience': '经验',
|
||||||
'special': '特殊属性\n\n0:无,1:先攻,2:魔攻,3:坚固,4:2连击,\n5:3连击,6:n连击,7:破甲,8:反击,9:净化,\n10:模仿,11:吸血,12:中毒,13:衰弱,14:诅咒,\n15:领域,16:夹击,17:仇恨,18:阻击,19:自爆,\n20:无敌\n\n多个属性例如用[1,4,11]表示先攻2连击吸血\n模仿怪的攻防设为0就好\n$leaf(true)$end',
|
'special': '特殊属性\n\n0:无,1:先攻,2:魔攻,3:坚固,4:2连击,\n5:3连击,6:n连击,7:破甲,8:反击,9:净化,\n10:模仿,11:吸血,12:中毒,13:衰弱,14:诅咒,\n15:领域,16:夹击,17:仇恨,18:阻击,19:自爆,\n20:无敌,21:退化,22:固伤\n\n多个属性例如用[1,4,11]表示先攻2连击吸血\n模仿怪的攻防设为0就好\n$leaf(true)$end',
|
||||||
'value': '特殊属性的数值\n领域怪需要加value表示领域伤害的数值\n吸血怪需要在后面添加value代表吸血比例',
|
'value': '特殊属性的数值\n领域怪需要加value表示领域伤害的数值\n吸血怪需要在后面添加value代表吸血比例',
|
||||||
'zoneSquare': '领域怪zoneSquare代表是否九宫格伤害',
|
'zoneSquare': '领域怪zoneSquare代表是否九宫格伤害',
|
||||||
'range': 'range可选,代表领域伤害的范围;不加默认为1\n$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end',
|
'range': 'range可选,代表领域伤害的范围;不加默认为1\n$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end',
|
||||||
'bomb':' 加入 "bomb": false 代表该怪物不可被炸弹或圣锤炸掉\n$select({\"values\":[true,false]})$end',
|
'bomb':' 加入 "bomb": false 代表该怪物不可被炸弹或圣锤炸掉\n$select({\"values\":[true,false]})$end',
|
||||||
'point': 'point可以在打败怪物后进行加点,详见文档说明\n$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end',
|
'point': 'point可以在打败怪物后进行加点,详见文档说明\n$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end',
|
||||||
'n': '多连击需要在后面指定n代表是几连击\n$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end',
|
'n': '多连击需要在后面指定n代表是几连击\n$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end',
|
||||||
|
'atkValue':'退化时勇士下降的攻击力点数\n$range(thiseval==~~thiseval||thiseval==null)$end',
|
||||||
|
'defValue':'退化时勇士下降的防御力点数\n$range(thiseval==~~thiseval||thiseval==null)$end',
|
||||||
|
'damage':'战前扣血的点数\n$range(thiseval==~~thiseval||thiseval==null)$end'
|
||||||
},
|
},
|
||||||
"enemys_template" : {'name': '新敌人', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
"enemys_template" : {'name': '新敌人', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
||||||
"floors" : {
|
"floors" : {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user