Merge branch 'v2.0' of https://github.com/ckcz123/mota-js into v2.0
This commit is contained in:
commit
dc35bc7adf
@ -181,4 +181,5 @@ fs.readdir(path, callback)
|
||||
|
||||
目前主体部分使用了 0-15,75,100
|
||||
|
||||
blockly使用 200 ,多行文本编辑器使用 300
|
||||
blockly使用 200,201
|
||||
多行文本编辑器使用 300
|
||||
@ -764,13 +764,13 @@ return code;
|
||||
*/
|
||||
|
||||
choices_s
|
||||
: '选项' ':' EvalString BGNL? '标题' EvalString? '图像' IdString? BGNL? Newline choicesContext+ BEND Newline
|
||||
: '选项' ':' EvalString? BGNL? '标题' EvalString? '图像' IdString? BGNL? Newline choicesContext+ BEND Newline
|
||||
;
|
||||
|
||||
/* choices_s
|
||||
tooltip : choices: 给用户提供选项
|
||||
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=choices-%e7%bb%99%e7%94%a8%e6%88%b7%e6%8f%90%e4%be%9b%e9%80%89%e9%a1%b9
|
||||
default : ["提示文字:选择一种钥匙","流浪者","woman"]
|
||||
default : ["","流浪者","woman"]
|
||||
var title='';
|
||||
if (EvalString_1==''){
|
||||
if (IdString_0=='')title='';
|
||||
@ -779,7 +779,9 @@ if (EvalString_1==''){
|
||||
if (IdString_0=='')title='\\t['+EvalString_1+']';
|
||||
else title='\\t['+EvalString_1+','+IdString_0+']';
|
||||
}
|
||||
var code = ['{"type": "choices", "text": "',title+EvalString_0,'", "choices": [\n',
|
||||
EvalString_0 = title+EvalString_0;
|
||||
EvalString_0 = EvalString_0 ?(', "text": "'+EvalString_0+'"'):'';
|
||||
var code = ['{"type": "choices"',EvalString_0,', "choices": [\n',
|
||||
choicesContext_0,
|
||||
']},\n'].join('');
|
||||
return code;
|
||||
@ -1315,7 +1317,7 @@ ActionParser.prototype.parseAction = function() {
|
||||
choice.text,this.insertActionList(choice.action),text_choices]);
|
||||
}
|
||||
this.next = MotaActionBlocks['choices_s'].xmlText([
|
||||
this.EvalString(data.text),'','',text_choices,this.next]);
|
||||
this.isset(data.text)?this.EvalString(data.text):null,'','',text_choices,this.next]);
|
||||
break;
|
||||
case "win":
|
||||
this.next = MotaActionBlocks['win_s'].xmlText([
|
||||
|
||||
@ -368,7 +368,7 @@ editor.prototype.listen = function() {
|
||||
var pos = locToPos(loc);
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('loc');
|
||||
editor_mode.loc();
|
||||
//editor_mode.loc();
|
||||
tip.whichShow = 1;
|
||||
return;
|
||||
}
|
||||
@ -530,7 +530,7 @@ editor.prototype.listen = function() {
|
||||
tip.infos = JSON.parse(JSON.stringify(editor.info));
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('emenyitem');
|
||||
editor_mode.emenyitem();
|
||||
//editor_mode.emenyitem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,8 +347,21 @@ editor_blockly.import = function(id_){
|
||||
return true;
|
||||
}
|
||||
|
||||
editor_blockly.show = function(){document.getElementById('left6').style='';}
|
||||
editor_blockly.hide = function(){document.getElementById('left6').style='z-index:-1;opacity: 0;';}
|
||||
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
|
||||
editor_blockly.show = function(){
|
||||
document.getElementById('left6').style='';
|
||||
for(var ii =0,node;node=blocklyWidgetDiv[ii];ii++){
|
||||
node.style.zIndex = 201;
|
||||
node.style.opacity = '';
|
||||
}
|
||||
}
|
||||
editor_blockly.hide = function(){
|
||||
document.getElementById('left6').style='z-index:-1;opacity: 0;';
|
||||
for(var ii =0,node;node=blocklyWidgetDiv[ii];ii++){
|
||||
node.style.zIndex = -1;
|
||||
node.style.opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.cancel = function(){
|
||||
editor_blockly.id='';
|
||||
|
||||
@ -149,10 +149,10 @@ editor_file = function(editor, callback){
|
||||
saveSetting('maps',[["add","['"+idnum+"']",{'cls': info.images, 'id':id}]],tempcallback);
|
||||
saveSetting('icons',[["add","['"+info.images+"']['"+id+"']",info.y]],tempcallback);
|
||||
if(info.images==='items'){
|
||||
saveSetting('items',[["change"/*其实应该是add*/,"['items']['"+id+"']",editor_file.comment.items_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
saveSetting('items',[["add","['items']['"+id+"']",editor_file.comment.items_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
}
|
||||
if(info.images==='enemys' || info.images==='enemy48'){
|
||||
saveSetting('enemys',[["change"/*其实应该是add*/,"['"+id+"']",editor_file.comment.enemys_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
saveSetting('enemys',[["add","['"+id+"']",editor_file.comment.enemys_template]],function(err){if(err){printe(err);throw(err)}});
|
||||
}
|
||||
|
||||
callback(null);
|
||||
@ -174,33 +174,47 @@ editor_file = function(editor, callback){
|
||||
});
|
||||
saveSetting('items',actionList,function (err) {
|
||||
callback([
|
||||
{'items':(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
/* locObj[v]=editor.core.items.items[id][v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
(function(){
|
||||
var locObj_ ={};
|
||||
Object.keys(editor_file.comment.items).forEach(function(v){
|
||||
if (isset(editor.core.items[v][id]) && v!=='items')
|
||||
locObj_[v]=editor.core.items[v][id];
|
||||
else
|
||||
locObj_[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
locObj_['items']=(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
})();
|
||||
return locObj_;
|
||||
})(),
|
||||
'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]},
|
||||
editor_file.comment.items,
|
||||
err]);
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
{'items':(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
/* locObj[v]=editor.core.items.items[id][v];
|
||||
else */
|
||||
locObj[v]=null;
|
||||
(function(){
|
||||
var locObj_ ={};
|
||||
Object.keys(editor_file.comment.items).forEach(function(v){
|
||||
if (isset(editor.core.items[v][id]) && v!=='items')
|
||||
locObj_[v]=editor.core.items[v][id];
|
||||
else
|
||||
locObj_[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
locObj_['items']=(function(){
|
||||
var locObj=Object.assign({},editor.core.items.items[id]);
|
||||
Object.keys(editor_file.comment.items.items).forEach(function(v){
|
||||
if (!isset(editor.core.items.items[id][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
return locObj;
|
||||
})();
|
||||
return locObj_;
|
||||
})(),
|
||||
'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]},
|
||||
editor_file.comment.items,
|
||||
null]);
|
||||
}
|
||||
@ -253,6 +267,49 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
//callback([obj,commentObj,err:String])
|
||||
|
||||
editor_file.editMapBlocksInfo = function(idnum,actionList,callback){
|
||||
/*actionList:[
|
||||
["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值,可参见样板中初级巫师的写法。"]],
|
||||
["change","['afterBattle']",null],
|
||||
]
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
|
||||
if (isset(actionList) && actionList.length > 0){
|
||||
actionList.forEach(function (value) {
|
||||
value[1] = "['"+idnum+"']"+value[1];
|
||||
});
|
||||
saveSetting('maps',actionList,function (err) {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment.maps).forEach(function(v){
|
||||
if (!isset(editor.core.maps.blocksInfo[idnum][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
locObj.idnum = idnum;
|
||||
return locObj;
|
||||
})(),
|
||||
editor_file.comment.maps,
|
||||
null]);
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
(function(){
|
||||
var locObj=Object.assign({},editor.core.maps.blocksInfo[idnum]);
|
||||
Object.keys(editor_file.comment.maps).forEach(function(v){
|
||||
if (!isset(editor.core.maps.blocksInfo[idnum][v]))
|
||||
locObj[v]=null;
|
||||
});
|
||||
locObj.idnum = idnum;
|
||||
return locObj;
|
||||
})(),
|
||||
editor_file.comment.maps,
|
||||
null]);
|
||||
}
|
||||
}
|
||||
//callback([obj,commentObj,err:String])
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_file.editLoc = function(x,y,actionList,callback){
|
||||
@ -479,13 +536,9 @@ editor_file = function(editor, callback){
|
||||
var saveSetting = function(file,actionList,callback) {
|
||||
//console.log(file);
|
||||
//console.log(actionList);
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change' && file!='icons' && file!='maps') {printe('目前只支持change');throw('目前只支持change')};
|
||||
});
|
||||
|
||||
if (file=='icons') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='add')return;
|
||||
eval("icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = \n';
|
||||
@ -497,7 +550,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='maps') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='add')return;
|
||||
eval("maps_90f36752_8815_4be8_b32b_d7fad1d0542e"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n';
|
||||
@ -517,7 +569,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='items') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = \n';
|
||||
@ -529,7 +580,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='enemys') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = \n';
|
||||
@ -546,7 +596,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='data') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr='data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = \n';
|
||||
@ -558,7 +607,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='functions') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("fmap[fobj"+value[1]+']='+JSON.stringify(value[2]));
|
||||
});
|
||||
var fraw = fjson;
|
||||
@ -574,7 +622,6 @@ editor_file = function(editor, callback){
|
||||
}
|
||||
if (file=='floors') {
|
||||
actionList.forEach(function (value) {
|
||||
if (value[0]!='change')return;
|
||||
eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2]));
|
||||
});
|
||||
editor_file.saveFloorFile(callback);
|
||||
|
||||
@ -182,6 +182,8 @@ editor_mode.prototype.doActionList = function(mode,actionList){
|
||||
editor.file.editEnemy(editor_mode.info.id,actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
} else if (editor_mode.info.images=='items'){
|
||||
editor.file.editItem(editor_mode.info.id,actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
} else {
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum,actionList,function(objs_){/*console.log(objs_);*/if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
|
||||
}
|
||||
break;
|
||||
case 'floor':
|
||||
@ -256,8 +258,9 @@ editor_mode.prototype.emenyitem = function(callback){
|
||||
} else if (editor_mode.info.images=='items'){
|
||||
editor.file.editItem(editor_mode.info.id,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
} else {
|
||||
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
|
||||
return;
|
||||
/* document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
|
||||
return; */
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum,[],function(objs_){objs=objs_;/*console.log(objs_)*/});
|
||||
}
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
|
||||
|
||||
@ -7,8 +7,8 @@ items.prototype.init = function () {
|
||||
this.items = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.items;
|
||||
this.itemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffect;
|
||||
this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip;
|
||||
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItem;
|
||||
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItem;
|
||||
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect;
|
||||
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect;
|
||||
//delete(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a);
|
||||
}
|
||||
|
||||
|
||||
@ -9,8 +9,8 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
},
|
||||
'itemEffect':'cls为items的即捡即用类物品的效果,执行时会对这里的字符串执行eval()',
|
||||
'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串',
|
||||
'useItem':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()',
|
||||
'canUseItem':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果',
|
||||
'useItemEffect':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()',
|
||||
'canUseItemEffect':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果',
|
||||
},
|
||||
"items_template" : {'cls': 'items', 'name': '新物品'},
|
||||
"enemys" : {
|
||||
@ -33,6 +33,13 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
'damage':'战前扣血的点数\n$range(thiseval==~~thiseval||thiseval==null)$end'
|
||||
},
|
||||
"enemys_template" : {'name': '新敌人', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'point': 0, 'special': 0},
|
||||
"maps" : {
|
||||
"id" : "$range(false)$end",
|
||||
"idnum" : "$range(false)$end",
|
||||
"cls" : "$range(false)$end",
|
||||
"trigger" : "$select({\"values\":[null,\"openDoor\",\"passNet\",\"changeLight\",\"ski\",\"pushBox\"]})$end",
|
||||
"noPass" : "$select({\"values\":[null,true,false]})$end"
|
||||
},
|
||||
"floors" : {
|
||||
'floor' : {
|
||||
"floorId": "文件名和floorId需要保持完全一致 \n楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 \n推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 \n楼层唯一标识符,需要和名字完全一致 \n这里不能更改floorId,请通过另存为来实现\n$range(false)$end",
|
||||
|
||||
@ -114,7 +114,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"moneyPocket":"',金币+'+core.values.moneyPocket",
|
||||
},
|
||||
|
||||
"useItem": {
|
||||
"useItemEffect": {
|
||||
"book": "core.ui.drawBook(0);",
|
||||
"fly": "core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));",
|
||||
"earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
|
||||
@ -145,7 +145,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"shield5": "core.plugin.useEquipment(itemId)",
|
||||
},
|
||||
|
||||
"canUseItem": {
|
||||
"canUseItemEffect": {
|
||||
"book": "true",
|
||||
"fly": "core.status.hero.flyRange.indexOf(core.status.floorId)>=0",
|
||||
"pickaxe": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&\n (block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙\n {\n // 四个方向\n if (core.flags.pickaxeFourDirections) {\n if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n }\n else {\n if (block.x == core.nextX() && block.y == core.nextY()) {\n ids.push(i);\n }\n }\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user