From b5bc7514a0682a955a3456d132104fd19e3b551f Mon Sep 17 00:00:00 2001 From: Dr Tracy Gardner Date: Thu, 15 Aug 2024 19:56:31 +0000 Subject: [PATCH] Moved to new plus minus mutator blocks --- blocks.js | 18 +++++++----------- dev-dist/sw.js | 2 +- generators.js | 18 +++++++++++------- package-lock.json | 12 ++++++++++++ package.json | 1 + 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/blocks.js b/blocks.js index a0633be..1c7c4d4 100644 --- a/blocks.js +++ b/blocks.js @@ -1,4 +1,5 @@ import * as Blockly from "blockly"; +import '@blockly/block-plus-minus'; import { categoryColours, toolbox } from "./toolbox.js"; import { audioNames, @@ -38,20 +39,15 @@ const options = { drag: true, wheel: true}, toolbox: toolbox, - /*plugins: { - // These are both required. - // Note that the ScrollBlockDragger drags things besides blocks. - // Block is included in the name for backwards compatibility. - blockDragger: ScrollBlockDragger, - metricsManager: ScrollMetricsManager, + plugins: { + + // blockDragger: ScrollBlockDragger, + //metricsManager: ScrollMetricsManager, }, - move: { - wheel: true, // Required for wheel scroll to work. - },*/ /*plugins: { - blockDragger: MultiselectBlockDragger, // Required to work + , // Required to work }, - +blockDragger: MultiselectBlockDragger, // // For integration with other plugins that also // // need to change the blockDragger above (such as // // scroll-options). diff --git a/dev-dist/sw.js b/dev-dist/sw.js index 125dfaf..4f5ba6e 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -91,7 +91,7 @@ define(['./workbox-07658ed7'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.ee2rf57q5d" + "revision": "0.ik8klbcnvsg" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/generators.js b/generators.js index c132a24..c0b3f30 100644 --- a/generators.js +++ b/generators.js @@ -1,5 +1,7 @@ import * as Blockly from "blockly"; import { javascriptGenerator } from "blockly/javascript"; +import '@blockly/block-plus-minus'; + import { FlowGraphLog10Block } from "babylonjs"; import { flock } from "./flock.js"; @@ -761,8 +763,9 @@ export function defineGenerators() { javascriptGenerator.forBlock["procedures_defnoreturn"] = function (block) { const functionName = block.getFieldValue("NAME"); // Retrieve the parameters as a comma-separated list - const params = block.arguments_; - console.log(block); + const args = block.argData_.map((elem) => elem.model.name); + const params = args.join(", "); + console.log(block, args); const branch = javascriptGenerator.statementToCode( block, @@ -770,8 +773,9 @@ export function defineGenerators() { javascriptGenerator.ORDER_NONE, ) || ""; + console.log(params); // Generate the function code with async and parameters - const code = `async function ${functionName}(${params.join(", ")}) {\n${branch}\n}`; + const code = `async function ${functionName}(${params}) {\n${branch}\n}`; return code; }; @@ -795,8 +799,8 @@ export function defineGenerators() { javascriptGenerator.forBlock["procedures_defreturn"] = function (block) { const functionName = block.getFieldValue("NAME"); - const params = block.arguments_ || []; // Ensuring this array is initialized correctly - const paramsCode = params.join(", "); // Creating a comma-separated string of parameters + const args = block.argData_.map((elem) => elem.model.name); + const params = args.join(", "); const branch = javascriptGenerator.statementToCode( block, @@ -811,7 +815,7 @@ export function defineGenerators() { ) || ""; // Generate the function code with async, parameters, and return statement - const code = `async function ${functionName}(${paramsCode}) {\n${branch}return ${returnValue};\n}`; + const code = `async function ${functionName}(${params}) {\n${branch}return ${returnValue}\n;}`; return code; }; @@ -828,7 +832,7 @@ export function defineGenerators() { ) || "null"; } - const code = `await ${functionName}\n(${args.join(", ")});\n`; + const code = `await ${functionName}\n(${args.join(", ")})\n`; return [code, javascriptGenerator.ORDER_ATOMIC]; }; diff --git a/package-lock.json b/package-lock.json index b24d78a..f3ff3d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@babylonjs/gui": "^7.8.0", "@babylonjs/havok": "^1.3.4", + "@blockly/block-plus-minus": "^8.0.7", "@blockly/block-shareable-procedures": "^5.0.6", "@blockly/field-colour": "^5.0.0", "@blockly/field-grid-dropdown": "^5.0.4", @@ -1817,6 +1818,17 @@ "babylonjs-gltf2interface": "^7.0.0" } }, + "node_modules/@blockly/block-plus-minus": { + "version": "8.0.7", + "resolved": "https://registry.npmjs.org/@blockly/block-plus-minus/-/block-plus-minus-8.0.7.tgz", + "integrity": "sha512-IFPmCZBm6BqSzy0iWWls8zt29kXHViRvuVF8f6g0zRk13yMNsvKN8shmW3ycP5F5pB6zXqJ35SpNW5bS2W/15Q==", + "engines": { + "node": ">=8.17.0" + }, + "peerDependencies": { + "blockly": "^11.0.0" + } + }, "node_modules/@blockly/block-shareable-procedures": { "version": "5.0.6", "resolved": "https://registry.npmjs.org/@blockly/block-shareable-procedures/-/block-shareable-procedures-5.0.6.tgz", diff --git a/package.json b/package.json index eeb3fdb..60a4f47 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dependencies": { "@babylonjs/gui": "^7.8.0", "@babylonjs/havok": "^1.3.4", + "@blockly/block-plus-minus": "^8.0.7", "@blockly/block-shareable-procedures": "^5.0.6", "@blockly/field-colour": "^5.0.0", "@blockly/field-grid-dropdown": "^5.0.4",