mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
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:
parent
f02433510a
commit
d9e0267fa0
1 changed files with 6 additions and 2 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue