Skip to content

Commit

Permalink
Moved to new plus minus mutator blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tracygardner committed Aug 15, 2024
1 parent 5d3deba commit b5bc751
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
18 changes: 7 additions & 11 deletions blocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Blockly from "blockly";
import '@blockly/block-plus-minus';
import { categoryColours, toolbox } from "./toolbox.js";
import {
audioNames,
Expand Down Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion dev-dist/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"), {
Expand Down
18 changes: 11 additions & 7 deletions generators.js
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -761,17 +763,19 @@ 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,
"STACK",
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;
};

Expand All @@ -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,
Expand All @@ -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;
};

Expand All @@ -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];
};
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b5bc751

Please sign in to comment.