Lua Script Error - attempt to compare boolean with number

General Q&A specific to RaceCapture/Pro. For app related questions post in the RaceCapture App forum. also see the <a href="http://www.autosportlabs.net/RaceCapture">RaceCapture Information Page</a>

Moderators: JeffC, rdoherty, stieg, brentp

Post Reply
UIMechEngr
Posts: 6
Joined: Wed Mar 16, 2022 11:52 pm

Lua Script Error - attempt to compare boolean with number

Post 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

-------------------------------------------------------------------------------------------------
Attachments
lua script woes.PNG
lua script woes.PNG (114 KiB) Viewed 7601 times

UIMechEngr
Posts: 6
Joined: Wed Mar 16, 2022 11:52 pm

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

Post 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

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

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

Post by brentp »

Glad you figured it out. Programming is fun!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply