mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-16 00:12:55 -04:00
Hack helper for distance sensors
This commit is contained in:
parent
85f8e99ca8
commit
5c03167ec3
3 changed files with 45 additions and 3 deletions
|
@ -288,6 +288,27 @@ Runtime.prototype.greenFlag = function () {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Distance sensor hack
|
||||
*/
|
||||
Runtime.prototype.startDistanceSensors = function () {
|
||||
// Add all top stacks with distance sensor
|
||||
for (var j = 0; j < this.stacks.length; j++) {
|
||||
var topBlock = this.stacks[j];
|
||||
if (this.blocks[topBlock].opcode === 'wedo_whendistanceclose') {
|
||||
var alreadyRunning = false;
|
||||
for (var k = 0; k < this.threads.length; k++) {
|
||||
if (this.threads[k].topBlock === topBlock) {
|
||||
alreadyRunning = true;
|
||||
}
|
||||
}
|
||||
if (!alreadyRunning) {
|
||||
this._pushThread(this.stacks[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop "everything"
|
||||
*/
|
||||
|
|
21
vm.js
21
vm.js
|
@ -1466,6 +1466,27 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Distance sensor hack
|
||||
*/
|
||||
Runtime.prototype.startDistanceSensors = function () {
|
||||
// Add all top stacks with distance sensor
|
||||
for (var j = 0; j < this.stacks.length; j++) {
|
||||
var topBlock = this.stacks[j];
|
||||
if (this.blocks[topBlock].opcode === 'wedo_whendistanceclose') {
|
||||
var alreadyRunning = false;
|
||||
for (var k = 0; k < this.threads.length; k++) {
|
||||
if (this.threads[k].topBlock === topBlock) {
|
||||
alreadyRunning = true;
|
||||
}
|
||||
}
|
||||
if (!alreadyRunning) {
|
||||
this._pushThread(this.stacks[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop "everything"
|
||||
*/
|
||||
|
|
6
vm.min.js
vendored
6
vm.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue