diff --git a/package.json b/package.json index 3e97458..21e6735 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "dist", "media" ], - "version": "3.2.4", + "version": "3.2.5", "description": "Leaphy custom Blockly blocks and arduino code generator", "name": "@leaphy-robotics/leaphy-blocks" } diff --git a/src/generators/arduino.ts b/src/generators/arduino.ts index dd51cc0..dcb6a5e 100644 --- a/src/generators/arduino.ts +++ b/src/generators/arduino.ts @@ -263,7 +263,8 @@ export class Arduino extends Blockly.Generator { lists.forEach((list) => { const type = this.TYPES[types[list.id][0] || "Number"]; - defLists.push(`List<${type}> ${list.name}`); + const name = list.name.replaceAll(" ", "_"); + defLists.push(`List<${type}> ${name}`); }); if (defLists.length) { diff --git a/src/generators/arduino/lists.ts b/src/generators/arduino/lists.ts index beb21df..3da8921 100644 --- a/src/generators/arduino/lists.ts +++ b/src/generators/arduino/lists.ts @@ -7,7 +7,7 @@ function getCodeGenerators(arduino: Arduino) { const value = arduino.valueToCode(block, "VALUE", arduino.ORDER_ATOMIC) || "0"; - const name = list.name.replace(" ", "_"); + const name = list.name.replaceAll(" ", "_"); return `${name}.add(${value});\n`; }; @@ -16,14 +16,14 @@ function getCodeGenerators(arduino: Arduino) { const index = arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0"; - const name = list.name.replace(" ", "_"); + const name = list.name.replaceAll(" ", "_"); return `${name}.remove(${index});\n`; }; arduino.forBlock["lists_clear"] = function (block) { const list = listManager.getList(block.getFieldValue("LIST")) as List; - const name = list.name.replace(" ", "_"); + const name = list.name.replaceAll(" ", "_"); return `${name}.clear();\n`; }; @@ -34,7 +34,7 @@ function getCodeGenerators(arduino: Arduino) { const index = arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0"; - const name = list.name.replace(" ", "_"); + const name = list.name.replaceAll(" ", "_"); return `${name}.addAtIndex(${index}, ${value});\n`; }; @@ -43,7 +43,7 @@ function getCodeGenerators(arduino: Arduino) { const index = arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0"; - const name = list.name.replace(" ", "_"); + const name = list.name.replaceAll(" ", "_"); return [`${name}.get(${index})`, arduino.ORDER_ATOMIC]; }; @@ -54,14 +54,14 @@ function getCodeGenerators(arduino: Arduino) { const index = arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0"; - const name = list.name.replace(" ", "_"); + const name = list.name.replaceAll(" ", "_"); return `${name}.remove(${index});\n${list.name}.addAtIndex(${index}, ${value});\n`; }; arduino.forBlock["lists_length"] = function (block) { const list = listManager.getList(block.getFieldValue("LIST")) as List; - const name = list.name.replace(" ", "_"); + const name = list.name.replaceAll(" ", "_"); return [`${name}.getSize()`, arduino.ORDER_ATOMIC]; }; }