mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Adding unit tests for new lookupOrCreate funciton, fixing a bug that came up during testing (using lookupVariableById on a null target). Skipping integration tests that do not work right now because SB2 import of broadcast message blocks has not been implemented yet.
This commit is contained in:
parent
b674a0c047
commit
e5378d323d
6 changed files with 54 additions and 10 deletions
|
@ -304,7 +304,14 @@ class Blocks {
|
|||
// 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)) {
|
||||
if (optRuntime.getEditingTarget()) {
|
||||
if (!optRuntime.getEditingTarget().lookupVariableById(e.varId)) {
|
||||
stage.createVariable(e.varId, e.varName, e.varType);
|
||||
}
|
||||
} else if (!stage.lookupVariableById(e.varId)) {
|
||||
// Since getEditingTarget returned null, we now need to
|
||||
// explicitly check if the stage has the variable, and
|
||||
// create one if not.
|
||||
stage.createVariable(e.varId, e.varName, e.varType);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue