Advertisement
JachyHm

OBE

Jul 20th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 0 0
  1. function Update ( deltaUpdateTimeFromGame )
  2.     deltaTime = math.abs(os.clock() - casMinuly)
  3.     casMinuly = os.clock()
  4.     if math.abs(deltaTime-deltaUpdateTimeFromGame) > 1 then
  5.         deltaTime = deltaUpdateTimeFromGame
  6.     end
  7.  
  8.         --OBE1-------------------------------------------------------------------------------
  9.         gBrzdicOBE1 = Call("GetControlValue", "OBE1", 0)
  10.         trainBrakeDirectValue = Call("GetControlValue", "TrainBrakeControlNonHUD", 0)
  11.        
  12.         koef = 0.75
  13.         doplnuj = false
  14.         if not gZasahVZ then
  15.             if gAutomatika == 0 then
  16.                 if gBrzdicOBE1 < 0.1 then --svih
  17.                     koef = 0.5
  18.                     doplnuj = true
  19.                 elseif gBrzdicOBE1 < 0.2 then --prebiti
  20.                     koef = 0.3
  21.                     doplnuj = true
  22.                 elseif gBrzdicOBE1 < 0.3 then --zaver
  23.                     koef = 0
  24.                 elseif gBrzdicOBE1 < 0.4 then --odbrzdeni
  25.                     koef = 0.15
  26.                     doplnuj = true
  27.                 elseif gBrzdicOBE1 < 0.55 then --jizda
  28.                     koef = 0
  29.                 elseif gBrzdicOBE1 < 0.7 then --brzdeni
  30.                     koef = 0.1
  31.                 end
  32.             elseif ((gBrzdicOBE1 > 0.53) or (gBrzdicOBE1 <= 0.54 and gOverSpeedActivated == false)) then
  33.                 if gBrzdicOBE1 < 0.1 then --svih
  34.                     koef = 0.5
  35.                     doplnuj = true
  36.                 elseif gBrzdicOBE1 < 0.2 then --prebiti
  37.                     koef = 0.3
  38.                     doplnuj = true
  39.                 elseif gBrzdicOBE1 < 0.3 then --zaver
  40.                     koef = 0
  41.                 elseif gBrzdicOBE1 < 0.4 then --odbrzdeni
  42.                     koef = 0.15
  43.                     doplnuj = true
  44.                 elseif gBrzdicOBE1 < 0.55 then --jizda
  45.                     koef = 0
  46.                 elseif gBrzdicOBE1 < 0.7 then --brzdeni
  47.                     koef = 0.1
  48.                 end
  49.             end
  50.         end
  51.        
  52.         if doplnuj then
  53.             trainBrakeDirectValue = math.max(trainBrakeDirectValue - (deltaTime * koef * math.sqrt(trainBrakeDirectValue)) / math.max((Call("GetConsistLength")-17)/100, 1),0)
  54.         else
  55.             trainBrakeDirectValue = math.min(trainBrakeDirectValue + (deltaTime * koef * math.sqrt(1-trainBrakeDirectValue)) / math.max((Call("GetConsistLength")-17)/100, 1),1)
  56.         end
  57.        
  58.         Call("SetControlValue", "TrainBrakeControlNonHUD", 0, trainBrakeDirectValue)
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement