Hey so, right now im writing a script to control the throttle of my train.
Right now, i want to make it so it goes up insteps, but u have full linear control of the actual throttle, if you are inbetween two different throttle steps then it will round to the nearest one (i dont know if that makes sense)
So say the player press forward throttle to here
|-----------------------|------------------------------------------------------------------|
2 ^ 3
Player throttle
I would want it to round and go to the left since thats where we are closest too.
If you need me to elaborate more then please do let me know but if anyone knows how to accomplish this it would be greatly appreciated
this is also my current chunk of code that controls throttle:
function throttleLoop()
coroutine.wrap( function ()
repeat
throttle = throttle + vehicleSeat.Throttle
if throttle > 80 then
throttle = 80
elseif throttle < -100 then
throttle = -100
end
if throttle < 0 then
env.TextBox.Text = string.format('%.1f%% Brake', throttle)
setNotch(throttle)
elseif throttle >= 0 then
env.TextBox.Text = string.format('%.1f%% Notch', throttle/20)
setNotch(throttle)
end
wait()
until false
end)()
end