mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Merge pull request #829 from kchadha/broadcast-message-typed-variable
Broadcast message functionality
This commit is contained in:
commit
a9e95f3b01
10 changed files with 164 additions and 39 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;
|
||||
|
@ -365,7 +372,8 @@ class Blocks {
|
|||
case 'field':
|
||||
// Update block value
|
||||
if (!block.fields[args.name]) return;
|
||||
if (args.name === 'VARIABLE' || args.name === 'LIST') {
|
||||
if (args.name === 'VARIABLE' || args.name === 'LIST' ||
|
||||
args.name === 'BROADCAST_OPTION') {
|
||||
// Get variable name using the id in args.value.
|
||||
const variable = optRuntime.getEditingTarget().lookupVariableById(args.value);
|
||||
if (variable) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue