Page 1 of 1

Lua Script Error - attempt to compare boolean with number

Posted: Sat Mar 26, 2022 8:11 pm
by UIMechEngr
I'm hoping someone can take quick look at the simple scripts I'm trying to run on my racecapture pro v3.

Basically I have the three GPIOs set to output mode and connected to a relay board. The intent of my scripts are just to cycle normally open and normally closed relays based on measured values. Seems really simple, and I looked at plenty of examples, but still can't get mine to work correctly.

I'm sure I'm just missing some basic syntax... this is definitely not my wheelhouse.

Error code when running the following script:
Script error: [string "function accusump()..."]:3.0: attempt to compare boolean with number

------------------------------------------------------------------------------------------------------------------

function accusump()
local rpm = getTimerRpm(0)
if 400 < rpm < 1750 then
setGpio(0, 1)
println ("Accusump Disabled")
else
setGpio(0, 0)
println ("Accusump Enabled")
end
end

function GenAlarm()
local OilPress = getAnalog(0)
local OilTemp = getAnalog(1)
if OilPress < 15 or OilTemp > 220 then
setGpio(1, 1)
println("panic")
else
println("No Panic")
setGpio(1, 0)
end
end

function onTick()
accusump()
GenAlarm()
end

-------------------------------------------------------------------------------------------------

Re: Lua Script Error - attempt to compare boolean with number

Posted: Sun Mar 27, 2022 3:19 pm
by UIMechEngr
Found the problem, just needed an AND

function accusump()
local rpm = getTimerRpm(0)
if 400 < rpm AND rpm < 1750 then
setGpio(0, 1)
println ("Accusump Disabled")
else
setGpio(0, 0)
println ("Accusump Enabled")
end
end

Re: Lua Script Error - attempt to compare boolean with number

Posted: Thu Mar 31, 2022 2:48 pm
by brentp
Glad you figured it out. Programming is fun!