mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 22:42:27 -05:00
Convert motor duration: seconds -> milliseconds
The block takes seconds, whereas the device takes milliseconds. Turning on a motor for 1 millisecond isn't very dramatic.
This commit is contained in:
parent
06fe701624
commit
cbfbc5d600
1 changed files with 3 additions and 2 deletions
|
@ -456,13 +456,14 @@ class Scratch3WeDo2Blocks {
|
||||||
* @return {Promise} - a promise which will resolve at the end of the duration.
|
* @return {Promise} - a promise which will resolve at the end of the duration.
|
||||||
*/
|
*/
|
||||||
motorOnFor (args) {
|
motorOnFor (args) {
|
||||||
|
const durationMS = args.DURATION * 1000;
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
this._forEachMotor(args.MOTOR_ID, motorIndex => {
|
this._forEachMotor(args.MOTOR_ID, motorIndex => {
|
||||||
this._device.motor(motorIndex).setMotorOnFor(args.DURATION);
|
this._device.motor(motorIndex).setMotorOnFor(durationMS);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ensure this block runs for a fixed amount of time even when no device is connected.
|
// Ensure this block runs for a fixed amount of time even when no device is connected.
|
||||||
setTimeout(resolve, args.DURATION);
|
setTimeout(resolve, durationMS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue