mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Fixing motor status setter to not clear rotation if already in rotation state.
This commit is contained in:
parent
5109cd474c
commit
75eae9a58a
1 changed files with 14 additions and 5 deletions
|
@ -432,7 +432,10 @@ class BoostMotor {
|
|||
*/
|
||||
set status (value) {
|
||||
// Clear any time- or rotation-related state from motor and set new status.
|
||||
if (value !== BoostMotorState.ON_FOR_ROTATION) {
|
||||
this._clearRotationState();
|
||||
console.log('clearing rotation state');
|
||||
}
|
||||
this._clearTimeout();
|
||||
this._status = value;
|
||||
}
|
||||
|
@ -494,6 +497,7 @@ class BoostMotor {
|
|||
* Turn this motor on indefinitely
|
||||
*/
|
||||
turnOnForever() {
|
||||
console.log('turnOnForever');
|
||||
this.status = BoostMotorState.ON_FOREVER;
|
||||
this._turnOn();
|
||||
|
||||
|
@ -505,6 +509,7 @@ class BoostMotor {
|
|||
* @param {number} milliseconds - run the motor for this long.
|
||||
*/
|
||||
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(
|
||||
|
@ -546,6 +552,7 @@ class BoostMotor {
|
|||
* @param {boolean} [useLimiter=true] - if true, use the rate limiter
|
||||
*/
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue