mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-03-13 17:04:39 -04:00
Merge pull request #1096 from towerofnix/warpspeed-vm
Implement "all at once" block
This commit is contained in:
commit
2b6f96ae0a
3 changed files with 39 additions and 1 deletions
|
@ -35,7 +35,8 @@ class Scratch3ControlBlocks {
|
|||
control_delete_this_clone: this.deleteClone,
|
||||
control_get_counter: this.getCounter,
|
||||
control_incr_counter: this.incrCounter,
|
||||
control_clear_counter: this.clearCounter
|
||||
control_clear_counter: this.clearCounter,
|
||||
control_all_at_once: this.allAtOnce
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -182,6 +183,16 @@ class Scratch3ControlBlocks {
|
|||
incrCounter () {
|
||||
this._counter++;
|
||||
}
|
||||
|
||||
allAtOnce (args, util) {
|
||||
// Since the "all at once" block is implemented for compatiblity with
|
||||
// Scratch 2.0 projects, it behaves the same way it did in 2.0, which
|
||||
// is to simply run the contained script (like "if 1 = 1").
|
||||
// (In early versions of Scratch 2.0, it would work the same way as
|
||||
// "run without screen refresh" custom blocks do now, but this was
|
||||
// removed before the release of 2.0.)
|
||||
util.startBranch(1, false);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Scratch3ControlBlocks;
|
||||
|
|
|
@ -899,6 +899,15 @@ const specMap = {
|
|||
argMap: [
|
||||
]
|
||||
},
|
||||
'warpSpeed': {
|
||||
opcode: 'control_all_at_once',
|
||||
argMap: [
|
||||
{
|
||||
type: 'input',
|
||||
inputName: 'SUBSTACK'
|
||||
}
|
||||
]
|
||||
},
|
||||
'touching:': {
|
||||
opcode: 'sensing_touchingobject',
|
||||
argMap: [
|
||||
|
|
|
@ -208,3 +208,21 @@ test('counter, incrCounter, clearCounter', t => {
|
|||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('allAtOnce', t => {
|
||||
const rt = new Runtime();
|
||||
const c = new Control(rt);
|
||||
|
||||
// Test harness (mocks `util`)
|
||||
let ran = false;
|
||||
const util = {
|
||||
startBranch: function () {
|
||||
ran = true;
|
||||
}
|
||||
};
|
||||
|
||||
// Execute test
|
||||
c.allAtOnce({}, util);
|
||||
t.true(ran);
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue