Resolves #2086. This issue was caused by turnOnForDegrees() not resolving a promise. Additionally, this promise can only be resolved if its assigned before turnOnDegrees() was called, so in motorOnForRotation() it is now switched around.

This commit is contained in:
Kevin Andersen 2019-04-05 14:18:33 -04:00
parent f02433510a
commit d9e0267fa0

View file

@ -471,7 +471,11 @@ class BoostMotor {
* @param {number} direction - rotate in this direction * @param {number} direction - rotate in this direction
*/ */
turnOnForDegrees (degrees, direction) { turnOnForDegrees (degrees, direction) {
if (this._power === 0) return; if (this._power === 0) {
this.pendingPromiseFunction();
return;
}
degrees = Math.max(0, degrees); degrees = Math.max(0, degrees);
const cmd = this._parent.generateOutputCommand( const cmd = this._parent.generateOutputCommand(
@ -1642,8 +1646,8 @@ class Scratch3BoostBlocks {
const motor = this._peripheral.motor(portID); const motor = this._peripheral.motor(portID);
if (motor) { if (motor) {
return new Promise(resolve => { return new Promise(resolve => {
motor.turnOnForDegrees(degrees, sign);
motor.pendingPromiseFunction = resolve; motor.pendingPromiseFunction = resolve;
motor.turnOnForDegrees(degrees, sign);
}); });
} }
return null; return null;