onTick

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

Moderators: JeffC, stieg

Post Reply
madjak
Posts: 29
Joined: Mon Jul 13, 2015 7:40 am

onTick

Post by madjak »

I'm trying to run multiple functions at different tick rates... what is the best way to achieve this? Below I've written a script that will process functions based on a modulus.


TickCount = 0

function onTick() --25Hz
processCAN()
ShiftLights()

if TickCount % 10 == 0 then --2.5Hz
runGearCalc()
end

if TickCount % 25 == 0 then --1Hz
runLoggingScript()
runDebugScrip()
end

TickCount = TickCount + 1
end

madjak
Posts: 29
Joined: Mon Jul 13, 2015 7:40 am

Post by madjak »

hmm it looks like Modulus (%) in Lua scripting doesn't work... any ideas?

madjak
Posts: 29
Joined: Mon Jul 13, 2015 7:40 am

Post by madjak »

here is my not-so-nice solution:

setTickRate(25)
TickArray = {0,0,0,0,0,0,0,0,0,1}
TickCount = 1
function onTick()

processCAN()
ShiftLights()

if (TickArray[TickCount] == 1 then
TickCount = 1
runLoggingScript()
runDebugScript()
end

TickCount = TickCount + 1

end


Basically processCAN and ShiftLights will run on 25Hz whilst the runLoggingScript and runDebugScript work ever 2.5Hz.

Post Reply