diff options
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r-- | advtrains/trainlogic.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index cc34b4f..6939275 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -300,6 +300,19 @@ function advtrains.train_ensure_init(id, train) run_callbacks_new_path(id, train) end + -- Check if the train has a driver + -- This will be useful for safety systems + train.has_driver = false + for i = 1, #train.trainparts, 1 do + if advtrains.wagons[train.trainparts[i]].has_driver then + train.has_driver = true + end + end + + if not train.sifa then + train.sifa = 0 + end + train.dirty = false -- TODO einbauen! return true end @@ -307,6 +320,10 @@ end function advtrains.train_step_b(id, train, dtime) if train.no_step or train.wait_for_path or not train.path then return end + -- Sifa + train.sifa = train.has_driver and (train.sifa+dtime) or 0 + train.ctrl.sifa = (train.sifa or 0) >=35 and 0 or nil + -- in this code, we check variables such as path_trk_? and path_dist. We need to ensure that the path is known for the whole 'Train' zone advtrains.path_get(train, atfloor(train.index + 2)) advtrains.path_get(train, atfloor(train.end_index - 1)) @@ -352,6 +369,7 @@ function advtrains.train_step_b(id, train, dtime) lzb = restrictive override from LZB user = User input from driverstand atc = ATC command override (determined here) + sifa = Sifa (requires driver attention) } The code here determines the precedence and writes the final control into train.lever ]] |