Resolves #2087 and #2088 for rotation-based commands.

There's quite a few interactions between degrees, their sign, and the currently set direction for the motor the degrees relate to. In this case, BoostMotor.turnOnDegrees() was being run with -degrees, and since that function does a Math.max between 0 and degrees, it resulted in 0 degrees.

Because of this, and for clarity, turnOnDegrees now only gets called with positive values. If running CCW, that should be specified in the direction-parameter.
This commit is contained in:
Kevin Andersen 2019-04-05 13:05:52 -04:00
parent e3cdbffa2a
commit 2c6a9d85cf

View file

@ -1719,8 +1719,8 @@ class Scratch3BoostBlocks {
if (motor.pendingTimeoutDelay) {
motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now());
} else if (motor.pendingPositionDestination) {
const p = motor.pendingPositionDestination - motor.position;
motor.turnOnForDegrees(p, Math.sign(p) * motor.direction);
const p = Math.abs(motor.pendingPositionDestination - motor.position);
motor.turnOnForDegrees(p, Math.sign(p));
}
}
}
@ -1758,8 +1758,8 @@ class Scratch3BoostBlocks {
if (motor.pendingTimeoutDelay) {
motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now());
} else if (motor.pendingPositionDestination) {
const p = motor.pendingPositionDestination - motor.position;
motor.turnOnForDegrees(p, Math.sign(p) * motor.direction);
const p = Math.abs(motor.pendingPositionDestination - motor.position);
motor.turnOnForDegrees(p, Math.sign(p));
}
}
}