mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-01 08:59:51 -04:00
Added a special case in motorOnForRotation() to avoid hanging blocks if power is 0
This commit is contained in:
parent
8ece9757aa
commit
a98f3af2e1
1 changed files with 2 additions and 0 deletions
|
@ -1695,6 +1695,8 @@ class Scratch3BoostBlocks {
|
||||||
const promises = motors.map(portID => {
|
const promises = motors.map(portID => {
|
||||||
const motor = this._peripheral.motor(portID);
|
const motor = this._peripheral.motor(portID);
|
||||||
if (motor) {
|
if (motor) {
|
||||||
|
// to avoid a hanging block if power is 0, return an immediately resolving promise.
|
||||||
|
if (motor.power === 0) return new Promise(resolve => resolve());
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
motor.turnOnForDegrees(degrees, sign);
|
motor.turnOnForDegrees(degrees, sign);
|
||||||
motor.pendingPromiseFunction = resolve;
|
motor.pendingPromiseFunction = resolve;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue