mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Don't set motor power if it's already equal to the input power.
This commit is contained in:
parent
71c3b72892
commit
c1292f6a59
1 changed files with 17 additions and 13 deletions
|
@ -1788,7 +1788,10 @@ 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) {
|
||||||
motor.power = MathUtil.clamp(Cast.toNumber(args.POWER), 0, 100);
|
const power = MathUtil.clamp(Cast.toNumber(args.POWER), 0, 100);
|
||||||
|
// if motor power is already equal to the scaled input power, don't do anything
|
||||||
|
if (motor.power !== MathUtil.scale(power, 1, 100, 10, 100)) {
|
||||||
|
motor.power = power;
|
||||||
switch (motor.status) {
|
switch (motor.status) {
|
||||||
case BoostMotorState.ON_FOREVER:
|
case BoostMotorState.ON_FOREVER:
|
||||||
motor.turnOnForever(false);
|
motor.turnOnForever(false);
|
||||||
|
@ -1803,6 +1806,7 @@ class Scratch3BoostBlocks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
|
|
Loading…
Reference in a new issue