Skip to content

Commit

Permalink
Fix variable increment
Browse files Browse the repository at this point in the history
Version 0.10.1 fixes a code generation bug when incrementing a variable.

The block "change 'some variable' by..." was generating incorrect, non-compilable code; this version fixes this bug.

Merge pull request #39 from haroldo-ok/fix-variable-increment
This fixes #36
  • Loading branch information
haroldo-ok authored Feb 20, 2023
2 parents 6c78c4b + 8e3de12 commit 9d28c96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vcs-game-maker",
"version": "0.10.0",
"version": "0.10.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
9 changes: 9 additions & 0 deletions src/generators/bbasic/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ export default (Blockly) => {
block.getFieldValue('VAR'), Blockly.VARIABLE_CATEGORY_NAME);
return varName + ' = ' + argument0 + '\n';
};

Blockly.BBasic['math_change'] = function(block) {
// Variable increment.
const argument0 = Blockly.BBasic.valueToCode(block, 'DELTA',
Blockly.BBasic.ORDER_ASSIGNMENT) || '0';
const varName = Blockly.BBasic.nameDB_.getName(
block.getFieldValue('VAR'), Blockly.VARIABLE_CATEGORY_NAME);
return varName + ' = ' + varName + ' + ' + argument0 + '\n';
};
};

0 comments on commit 9d28c96

Please sign in to comment.