mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Don't set motor power or direction if in rotation state.
This commit is contained in:
parent
8745c9b3ac
commit
2a04e9c7f2
1 changed files with 8 additions and 22 deletions
|
@ -1788,23 +1788,14 @@ class Scratch3BoostBlocks {
|
||||||
this._forEachMotor(args.MOTOR_ID, motorIndex => {
|
this._forEachMotor(args.MOTOR_ID, motorIndex => {
|
||||||
const motor = this._peripheral.motor(motorIndex);
|
const motor = this._peripheral.motor(motorIndex);
|
||||||
if (motor) {
|
if (motor) {
|
||||||
const power = MathUtil.clamp(Cast.toNumber(args.POWER), 0, 100);
|
motor.power = MathUtil.clamp(Cast.toNumber(args.POWER), 0, 100);
|
||||||
// if motor power is already equal to the scaled input power, don't do anything
|
switch (motor.status) {
|
||||||
if (motor.power !== MathUtil.scale(power, 1, 100, 10, 100)) {
|
case BoostMotorState.ON_FOREVER:
|
||||||
motor.power = power;
|
motor.turnOnForever(false);
|
||||||
switch (motor.status) {
|
break;
|
||||||
case BoostMotorState.ON_FOREVER:
|
case BoostMotorState.ON_FOR_TIME:
|
||||||
motor.turnOnForever(false);
|
motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now(), false);
|
||||||
break;
|
break;
|
||||||
case BoostMotorState.ON_FOR_TIME:
|
|
||||||
motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now(), false);
|
|
||||||
break;
|
|
||||||
case BoostMotorState.ON_FOR_ROTATION: {
|
|
||||||
const p = Math.abs(motor.pendingPositionDestination - motor.position, false);
|
|
||||||
motor.turnOnForDegrees(p, Math.sign(p));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1851,11 +1842,6 @@ class Scratch3BoostBlocks {
|
||||||
case BoostMotorState.ON_FOR_TIME:
|
case BoostMotorState.ON_FOR_TIME:
|
||||||
motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now(), false);
|
motor.turnOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now(), false);
|
||||||
break;
|
break;
|
||||||
case BoostMotorState.ON_FOR_ROTATION: {
|
|
||||||
const p = Math.abs(motor.pendingPositionDestination - motor.position);
|
|
||||||
motor.turnOnForDegrees(p, Math.sign(p), false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue