From d126f799d817973ef597785727b8bd2ccdcf0f31 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 25 Oct 2017 11:16:42 -0400 Subject: [PATCH] Prevent imported local variables from being duplicated on the stage. --- src/engine/blocks.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index f25827b39..ba9077fc7 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -255,7 +255,13 @@ class Blocks { }); break; case 'var_create': - stage.createVariable(e.varId, e.varName); + // New variables being created by the user are all global. + // Check if this variable exists on the current target or stage. + // If not, create it on the stage. + // TODO create global and local variables when UI provides a way. + if (!optRuntime.getEditingTarget().lookupVariableById(e.varId)) { + stage.createVariable(e.varId, e.varName); + } break; case 'var_rename': stage.renameVariable(e.varId, e.newName);