RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
[Solved] Help with Brake script on wiki
Author Message
Reply with quote
Post [Solved] Help with Brake script on wiki 
Here is my script. Where did I go wrong or why did it stop on the MaxDecel?

MaxDecelG = 1.20
chBrake = addChannel("vBrake", 25, 0, 0, 100, ' ')

function updatevBrake()
BrakeG = getChannel(LongAccel)
BrakePos = (BrakeG/MaxDecelG)*100

if BrakePos < 10 then BrakePos = 0 end
BrakePos = math.abs(BrakePos)
if BrakePos > 99 then BrakePos = 100 end
setChannel(chBrake, BrakePos)
end

setTickRate(25)
function onTick()
updatevBrake()
end

Here is the error

[lua] Successfully loaded script.
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Failure: Runtime Error
[lua] Gracefully stopping Lua Task
[lua] Destroying Lua State
[lua] Initializing Lua state
[lua] memory usage: 17KB
[lua] Starting Lua Task
[lua] Loading script. Length: 354
timebase/logging/telemetry sample rate: 100/100/50
[lua] Successfully loaded script.
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Failure: Runtime Error



Last edited by Canyonfive on Fri Aug 07, 2020 8:15 pm; edited 1 time in total
View user's profile Send private message
Reply with quote
Post  
Thought it might be the uppercase in the variables but no it still fails

View user's profile Send private message
Reply with quote
Post  
Even though I'm on the current firmware it looks like it worked with getImu instead of getChannel.


MaxDecelG = 1.20
chBrake = addChannel("vBrake", 25, 0, 0, 100, ' ')

function updatevBrake()
BrakeG = getImu(1)
BrakePos = (BrakeG/MaxDecelG)*100

if BrakePos < 10 then BrakePos = 0 end
BrakePos = math.abs(BrakePos)
if BrakePos > 99 then BrakePos = 100 end
setChannel(chBrake, BrakePos)
end

setTickRate(25)
function onTick()
updatevBrake()
end

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum