Hack helper for distance sensors

This commit is contained in:
Tim Mickel 2016-05-03 17:39:02 -04:00
parent 85f8e99ca8
commit 5c03167ec3
3 changed files with 45 additions and 3 deletions

View file

@ -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
View file

@ -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

File diff suppressed because one or more lines are too long