mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-11 04:51:15 -04:00
fix: stop motor when power set to 0
When motor power set to 0, the motor stops.
This commit is contained in:
parent
7313ce5199
commit
ba32baa3c6
1 changed files with 5 additions and 1 deletions
|
@ -1375,7 +1375,11 @@ class Scratch3WeDo2Blocks {
|
|||
this._forEachMotor(args.MOTOR_ID, motorIndex => {
|
||||
const motor = this._peripheral.motor(motorIndex);
|
||||
if (motor) {
|
||||
motor.power = MathUtil.clamp(Cast.toNumber(args.POWER), 0, 100);
|
||||
const power = MathUtil.clamp(Cast.toNumber(args.POWER), 0, 100);
|
||||
if (power === 0) {
|
||||
motor.turnOff();
|
||||
}
|
||||
motor.power = power;
|
||||
motor.turnOn();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue