Script Check - Virtual channels with math

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="">Lua Scripting Guide</a>

Moderators: JeffC, stieg

Post Reply
Posts: 97
Joined: Fri Feb 12, 2016 11:27 pm
Location: NY

Script Check - Virtual channels with math

Post by PS14 »

Would someone check this script and let me know if it looks right. I am pulling two 1600psi brake pressure senders in via AnalogX and want to create a virtual channel (gauge) that shows the percentage of one against the total of the two (to show brake bias %). thanks, Dave

--Create Virtual Channels:
vfbrakeId = addChannel("vfbrake", 10, 0, 0, 1600, "psi")
vrbrakeId = addChannel("vrbrake", 10, 0, 0, 1600, "psi")
bbsId = addChannel("BrakeBias", 10, 0, 0, 100, "%")

function processCan()
id, ext, data = rxCAN(0)
if id == 935444 then
setChannel(vfbrakeId, data[7], 16, 40, -200)
setChannel(vrbrakeId, data[9], 16, 40, -200)

function setChannel()
local a1 = vfbrake()
local a2 = vrbrake()
setChannel(bbsId, (a2 / (a1 + a2)))

function onTick()

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

Post by brentp »

Hi, this looks like a duplicate of the conversation you have in the AnalogX section? if so we can continue it there.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply