Is anyone using this script or having any issues with it?
I tried using this script with 2.8.5 and 1.3.13 but am getting an error message. "lua: startup script error: ([string " ..."]:83.0: malformed number near '1stGear')"
Here is the script I am trying.
--below values are constants for the vehicle
local 1stGear = 2.66
local 2ndGear = 1.78
local 3rdGear = 1.3
local 4thGear = 1.0
local 5thGear = 0.74
local 6thGear = 0.50
local FinalDrive = 4.10
--diameter in inches
local TireDia = 25.1
--allowable error of gear ratio to allow for measurement variation
local gearErr = 0.1
local rpmSpeedRatio = 0
--initialized to 0 so if it doesn't work you know
local gearPos = 0 --this is the gear channel variable
function onTick() --updates gear position every second by default
--assumes Pulse Input channel one is for the RPM signal and speed in MPH
local speed = getGpsSpeed()
local rpm = getTimerRpm(0)
--this part only works for firmware version 2.0 per the RCP page
gearId = addChannel("Gear",5)
if speed > 10 then
--makes sure your rolling so as not to divide by 0
rpmSpeedRatio = (rpm/speed)/(FinalDrive*1056/(TireDia*3.14159))
if ((1stGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 1 end
if ((2ndGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 2 end
if ((3rdGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 3 end
if ((4thGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 4 end
if ((5thGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 5 end
if ((6thGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 6 end
else gearPos = 0 end
setChannel(gearId, gearPos) --outputs to virtual channel
end
I also put the script in
http://ideone.com/RvZmRF and received the error message
" Compilation error time: 0 memory: 0 signal:0 luac: prog.lua:2: <name> expected near '1' " on line 2 of the script.