onTick
Posted: Wed Jul 29, 2015 4:53 am
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
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