diff --git a/src/util/visit.ts b/src/util/visit.ts index 9aafe3a..d9c1d1d 100644 --- a/src/util/visit.ts +++ b/src/util/visit.ts @@ -146,6 +146,9 @@ export class Visitor { blockToExpression(block: Block | number | string): Expression { if (typeof block == "number") return block.toString() as Expression + + if (!Number.isNaN(Number(block))) + return Number(block).toString() as Expression if (typeof block == "string") return stringExpr(block) @@ -153,12 +156,8 @@ export class Visitor { if (!block) return "" as Expression - if (block.type == "number") - return block.params[0]!.toString() as Expression - - if (block.type == "text") { - return stringExpr(String(block.params[0] as string | number)) - } + if (block.type == "number" || block.type == "text") + return this.blockToExpression(block.params[0]!) if ( block.type.startsWith("stringParam_") diff --git a/test/fib.js b/test/fib.js index 5640894..a9af565 100644 --- a/test/fib.js +++ b/test/fib.js @@ -1,5 +1,5 @@ init({objects:[{id:'ctqk',name:'새 오브젝트2',objectType:'sprite',rotateMethod:'free',scene:'7dwq',sprite:{pictures:[{id:'nrzz',dimension:{width:960,height:540,scaleX:0.5,scaleY:0.5},fileurl:'/lib/entry-js/images/_1x1.png',name:'새그림',imageType:'png'}],sounds:[]},selectedPictureId:'nrzz',lock:false,entity:{x:0,y:0,regX:480,regY:270,scaleX:0.5,scaleY:0.5,rotation:0,direction:90,width:960,height:540,font:'undefinedpx ',visible:true}}],scenes:[{id:'7dwq',name:'장면 1'}],variables:[{name:'초시계',id:'brih',visible:false,value:0,variableType:'timer',isCloud:false,isRealTime:false,cloudDate:false,object:null,x:134,y:-70},{name:' 대답 ',id:'1vu8',visible:false,value:'0',variableType:'answer',isCloud:false,isRealTime:false,cloudDate:false,object:null,x:150,y:-100}],messages:[],functions:[{id:'zlc2',type:'value',localVariables:[{name:'지역변수',value:0,id:'zlc2_wmnl'}],useLocalVariables:true}],tables:[],speed:60,interface:{menuWidth:280,canvasWidth:480,object:'ctqk'},expansionBlocks:[],aiUtilizeBlocks:[],hardwareLiteBlocks:[],externalModules:[],externalModulesLite:[]}) -Entry.func_zlc2 = (stringParam_08l7, obj) => {let v_zlc2_wmnl; Entry.if_else(Entry.boolean_basic_operator(stringParam_08l7, "LESS_OR_EQUAL", "2", obj), () => {v_zlc2_wmnl = "1"}, () => {v_zlc2_wmnl = Entry.calc_basic(Entry.func_zlc2(Entry.calc_basic(stringParam_08l7, "MINUS", 1, obj), obj), "PLUS", Entry.func_zlc2(Entry.calc_basic(stringParam_08l7, "MINUS", 2, obj), obj), obj)}, obj); return v_zlc2_wmnl} +Entry.func_zlc2 = (stringParam_08l7, obj) => {let v_zlc2_wmnl; Entry.if_else(Entry.boolean_basic_operator(stringParam_08l7, "LESS_OR_EQUAL", 2, obj), () => {v_zlc2_wmnl = 1}, () => {v_zlc2_wmnl = Entry.calc_basic(Entry.func_zlc2(Entry.calc_basic(stringParam_08l7, "MINUS", 1, obj), obj), "PLUS", Entry.func_zlc2(Entry.calc_basic(stringParam_08l7, "MINUS", 2, obj), obj), obj)}, obj); return v_zlc2_wmnl} -Entry.when_run_button_click(() => {Entry.dialog(Entry.func_zlc2("10", "ctqk"), "speak", "ctqk")}, "ctqk") \ No newline at end of file +Entry.when_run_button_click(() => {Entry.dialog(Entry.func_zlc2(10, "ctqk"), "speak", "ctqk")}, "ctqk") \ No newline at end of file diff --git a/test/proj1.js b/test/proj1.js index 1601203..3e9ac20 100644 --- a/test/proj1.js +++ b/test/proj1.js @@ -2,5 +2,5 @@ init({objects:[{id:'7y0y',name:'엔트리봇',objectType:'sprite',rotateMethod:' -Entry.when_run_button_click(() => {Entry.if_else(Entry.boolean_basic_operator(Entry.calc_basic(10, "PLUS", 10, "7y0y"), "LESS", "2", "7y0y"), () => {Entry.dialog("안녕!", "speak", "7y0y"); Entry.change_to_some_shape(Entry.get_pictures("4t48", "7y0y"), "7y0y")}, () => {Entry.move_x(10, "7y0y")}, "7y0y")}, "7y0y") -Entry.when_some_key_pressed("81", () => {Entry.locate_object_time(2, "mouse", "7y0y")}, "7y0y") \ No newline at end of file +Entry.when_run_button_click(() => {Entry.if_else(Entry.boolean_basic_operator(Entry.calc_basic(10, "PLUS", 10, "7y0y"), "LESS", 2, "7y0y"), () => {Entry.dialog("안녕!", "speak", "7y0y"); Entry.change_to_some_shape(Entry.get_pictures("4t48", "7y0y"), "7y0y")}, () => {Entry.move_x(10, "7y0y")}, "7y0y")}, "7y0y") +Entry.when_some_key_pressed(81, () => {Entry.locate_object_time(2, "mouse", "7y0y")}, "7y0y") \ No newline at end of file diff --git a/test/proj2.js b/test/proj2.js index 924d823..9984270 100644 --- a/test/proj2.js +++ b/test/proj2.js @@ -2,4 +2,4 @@ init({objects:[{id:'7y0y',name:'엔트리봇',objectType:'sprite',rotateMethod:' Entry.func_j0wh = (stringParam_66j8, obj) => {Entry.dialog(stringParam_66j8, "speak", obj)} -Entry.when_run_button_click(() => {Entry.func_j0wh("123", "7y0y")}, "7y0y") \ No newline at end of file +Entry.when_run_button_click(() => {Entry.func_j0wh(123, "7y0y")}, "7y0y") \ No newline at end of file