Why this is not working?

Hi,
why this code isnt working

steerSpeed = (steerSpeed > config.steer*steerStep) and (steerSpeed - config.steerAceleration) or ((steerSpeed < config.steer*steerStep) and (steerSpeed + config.steerAceleration))

and its giving error:
atemp to compare number and boolean

Why do you need one line, although this might not be the case?

It makes it harder to understand why it’s broken.

In my mind two things could be happening:

  1. config.steer or steerStep are booleans and need to be numbers.

  2. At some point in time, steerSpeed == config.steer*steerStep. In this case, your first comparison case will be false, but your second will be false as well. This makes steerSpeed become a boolean (false) instead of a number. If you’re constantly updating steerSpeed, this makes the next update cause the error because steerSpeed is now a boolean. If this is happening then you should consider changing your code to allow for the case when steerSpeed is equal to the comparison

In either case, it might be simpler just to break up steerSpeed into a multi-line if statement.

1 Like

its case 2, I added or 0 at end, thx