Fixing motor direction block to also work when the motor is on indefinitely.

This commit is contained in:
Evelyn Eastmond 2018-08-15 14:01:08 -04:00
parent 82df80a04c
commit 35a2411f92

View file

@ -995,9 +995,13 @@ class Scratch3WeDo2Blocks {
log.warn(`Unknown motor direction in setMotorDirection: ${args.DIRECTION}`); log.warn(`Unknown motor direction in setMotorDirection: ${args.DIRECTION}`);
break; break;
} }
// keep the motor on if it's running, and update the pending timeout // keep the motor on if it's running, and update the pending timeout if needed
if (motor.isOn && motor.pendingTimeoutDelay) { if (motor.isOn) {
motor.setMotorOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now()); if (motor.pendingTimeoutDelay) {
motor.setMotorOnFor(motor.pendingTimeoutStartTime + motor.pendingTimeoutDelay - Date.now());
} else {
motor.setMotorOn();
}
} }
} }
}); });