mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-02 01:22:31 -04:00
Hacked implementation of broadcasts
This commit is contained in:
parent
326e03b5d2
commit
9363432456
4 changed files with 86 additions and 8 deletions
src/engine
|
@ -137,6 +137,32 @@ Sequencer.prototype.stepThread = function (thread) {
|
|||
thread.stackFrames.pop();
|
||||
};
|
||||
|
||||
/**
|
||||
* A callback for the primitive to start hats.
|
||||
* @todo very hacked...
|
||||
*/
|
||||
var startHats = function(callback) {
|
||||
for (var i = 0; i < instance.runtime.stacks.length; i++) {
|
||||
var stack = instance.runtime.stacks[i];
|
||||
var stackBlock = instance.runtime.blocks[stack];
|
||||
var result = callback(stackBlock);
|
||||
if (result) {
|
||||
// Check if the stack is already running
|
||||
var stackRunning = false;
|
||||
|
||||
for (var j = 0; j < instance.runtime.threads.length; j++) {
|
||||
if (instance.runtime.threads[j].topBlock == stack) {
|
||||
stackRunning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!stackRunning) {
|
||||
instance.runtime._pushThread(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Record whether we have switched stack,
|
||||
* to avoid proceeding the thread automatically.
|
||||
|
@ -191,7 +217,8 @@ Sequencer.prototype.stepThread = function (thread) {
|
|||
done: threadDoneCallback,
|
||||
timeout: YieldTimers.timeout,
|
||||
stackFrame: currentStackFrame,
|
||||
startSubstack: threadStartSubstack
|
||||
startSubstack: threadStartSubstack,
|
||||
startHats: startHats
|
||||
});
|
||||
}
|
||||
catch(e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue