From 75eae9a58aff46aedf483f12879ecd693bea5ae8 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Sun, 28 Apr 2019 20:42:38 -0400 Subject: [PATCH] Fixing motor status setter to not clear rotation if already in rotation state. --- src/extensions/scratch3_boost/index.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 7544657a9..ec776a473 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -432,7 +432,10 @@ class BoostMotor { */ set status (value) { // Clear any time- or rotation-related state from motor and set new status. - this._clearRotationState(); + if (value !== BoostMotorState.ON_FOR_ROTATION) { + this._clearRotationState(); + console.log('clearing rotation state'); + } this._clearTimeout(); this._status = value; } @@ -493,7 +496,8 @@ class BoostMotor { /** * Turn this motor on indefinitely */ - turnOnForever (){ + turnOnForever() { + console.log('turnOnForever'); this.status = BoostMotorState.ON_FOREVER; this._turnOn(); @@ -504,7 +508,8 @@ class BoostMotor { * Turn this motor on for a specific duration. * @param {number} milliseconds - run the motor for this long. */ - turnOnFor (milliseconds) { + turnOnFor(milliseconds) { + console.log('turnOnFor'); milliseconds = Math.max(0, milliseconds); this.status = BoostMotorState.ON_FOR_TIME; this._turnOn(); @@ -519,6 +524,7 @@ class BoostMotor { * @param {number} direction - rotate in this direction */ turnOnForDegrees (degrees, direction) { + console.log('turnOnForDegrees'); degrees = Math.max(0, degrees); const cmd = this._parent.generateOutputCommand( @@ -545,7 +551,8 @@ class BoostMotor { * Turn this motor off. * @param {boolean} [useLimiter=true] - if true, use the rate limiter */ - turnOff (useLimiter = true) { + turnOff(useLimiter = true) { + console.log('turnOff'); const cmd = this._parent.generateOutputCommand( this._index, BoostOutputExecution.EXECUTE_IMMEDIATELY ^ BoostOutputExecution.COMMAND_FEEDBACK, @@ -1727,7 +1734,9 @@ class Scratch3BoostBlocks { * Make sure all promises are resolved, i.e. all motor-commands have completed. * To prevent the block from returning a value, an empty function is added to the .then */ - return Promise.all(promises).then(() => {}); + return Promise.all(promises).then(() => { + console.log('motorOnForRotation resolved'); + }); } /**