store broadcastVar on stackFrame to prevent canceling

a broadcast early if the variable changes
This commit is contained in:
Eric Rosenbaum 2020-08-12 11:21:55 -04:00
parent 5f10125643
commit a2b4cf8cfb

View file

@ -90,10 +90,12 @@ class Scratch3EventBlocks {
} }
broadcastAndWait (args, util) { broadcastAndWait (args, util) {
const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg( if (!util.stackFrame.broadcastVar) {
util.stackFrame.broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(
args.BROADCAST_OPTION.id, args.BROADCAST_OPTION.name); args.BROADCAST_OPTION.id, args.BROADCAST_OPTION.name);
if (broadcastVar) { }
const broadcastOption = broadcastVar.name; if (util.stackFrame.broadcastVar) {
const broadcastOption = util.stackFrame.broadcastVar.name;
// Have we run before, starting threads? // Have we run before, starting threads?
if (!util.stackFrame.startedThreads) { if (!util.stackFrame.startedThreads) {
// No - start hats for this broadcast. // No - start hats for this broadcast.