mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Fixing #1567: EV3 motor position reporter gets inverted.
This commit is contained in:
parent
f467d2d01f
commit
fe288902fa
1 changed files with 7 additions and 7 deletions
|
@ -231,14 +231,10 @@ class EV3Motor {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return {int} - this motor's current position, in the range [0,360].
|
||||
* @return {int} - this motor's current position, in the range [-inf,inf].
|
||||
*/
|
||||
get position () {
|
||||
let value = this._position;
|
||||
value = value % 360;
|
||||
value = value < 0 ? value * -1 : value;
|
||||
|
||||
return value;
|
||||
return this._position;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1156,8 +1152,12 @@ class Scratch3Ev3Blocks {
|
|||
}
|
||||
|
||||
const motor = this._peripheral.motor(port);
|
||||
let position = 0;
|
||||
if (motor) {
|
||||
position = MathUtil.wrapClamp(motor.position, 0, 360);
|
||||
}
|
||||
|
||||
return motor ? motor.position : 0;
|
||||
return position;
|
||||
}
|
||||
|
||||
whenButtonPressed (args) {
|
||||
|
|
Loading…
Reference in a new issue