[Solved] Help with Brake script on wiki
Posted: Fri Jul 31, 2020 4:17 am
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
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