mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Merge pull request #361 from thisandagain/bugfix/360
Fix hat blocks in horizontal grammar
This commit is contained in:
commit
bc60fa13ce
1 changed files with 13 additions and 0 deletions
|
@ -435,12 +435,24 @@ Runtime.prototype.startHats = function (requestedHatOpcode,
|
||||||
// Not the right hat.
|
// Not the right hat.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match any requested fields.
|
// Match any requested fields.
|
||||||
// For example: ensures that broadcasts match.
|
// For example: ensures that broadcasts match.
|
||||||
// This needs to happen before the block is evaluated
|
// This needs to happen before the block is evaluated
|
||||||
// (i.e., before the predicate can be run) because "broadcast and wait"
|
// (i.e., before the predicate can be run) because "broadcast and wait"
|
||||||
// needs to have a precise collection of started threads.
|
// needs to have a precise collection of started threads.
|
||||||
var hatFields = target.blocks.getFields(topBlockId);
|
var hatFields = target.blocks.getFields(topBlockId);
|
||||||
|
|
||||||
|
// If no fields are present, check inputs (horizontal blocks)
|
||||||
|
if (Object.keys(hatFields).length === 0) {
|
||||||
|
var hatInputs = target.blocks.getInputs(topBlockId);
|
||||||
|
for (var input in hatInputs) {
|
||||||
|
var id = hatInputs[input].block;
|
||||||
|
var fields = target.blocks.getFields(id);
|
||||||
|
hatFields = Object.assign(fields, hatFields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (optMatchFields) {
|
if (optMatchFields) {
|
||||||
for (var matchField in optMatchFields) {
|
for (var matchField in optMatchFields) {
|
||||||
if (hatFields[matchField].value !==
|
if (hatFields[matchField].value !==
|
||||||
|
@ -450,6 +462,7 @@ Runtime.prototype.startHats = function (requestedHatOpcode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up metadata for the relevant hat.
|
// Look up metadata for the relevant hat.
|
||||||
var hatMeta = instance._hats[requestedHatOpcode];
|
var hatMeta = instance._hats[requestedHatOpcode];
|
||||||
if (hatMeta.restartExistingThreads) {
|
if (hatMeta.restartExistingThreads) {
|
||||||
|
|
Loading…
Reference in a new issue