pass message to upvar

snap7
Zak Kolar 2021-12-28 18:17:05 -06:00
rodzic 7394c69a27
commit 3a7a6e8ad9
1 zmienionych plików z 32 dodań i 11 usunięć

Wyświetl plik

@ -135,16 +135,37 @@ IDE_Morph.prototype.broadcast = function(message, callback) {
throw new Error('message must be a String'); throw new Error('message must be a String');
} }
this.stage.lastMessage = message; this.stage.lastMessage = message;
rcvrs.forEach(sprite => { rcvrs.forEach(morph => {
sprite.allHatBlocksFor(message).forEach(block => { if (isSnapObject(morph)) {
morph.allHatBlocksFor(message).forEach(block => {
var varName, varFrame;
if (block.selector === 'receiveMessage') {
varName = block.inputs()[1].evaluate()[0];
if (varName) {
varFrame = new VariableFrame();
varFrame.addVar(varName, message);
}
procs.push(this.stage.threads.startProcess( procs.push(this.stage.threads.startProcess(
block, block,
sprite, morph,
this.stage.isThreadSafe, this.stage.isThreadSafe || // make "any msg" threadsafe
false, block.inputs()[0].evaluate() instanceof Array,
callback instanceof Function ? wait : null null, // exportResult (bool)
callback instanceof Function ? wait : null,
null, // isClicked
null, // rightAway
null, // atomic
varFrame
)); ));
} else {
procs.push(stage.threads.startProcess(
block,
morph,
stage.isThreadSafe
));
}
}); });
}
}); });
(this.stage.messageCallbacks[''] || []).forEach( (this.stage.messageCallbacks[''] || []).forEach(
callback => callback(message) callback => callback(message)