diff options
author | ywang <yw05@forksworld.de> | 2021-01-19 17:41:09 +0100 |
---|---|---|
committer | ywang <yw05@forksworld.de> | 2021-01-20 17:28:01 +0100 |
commit | 61d0378ad6b988e6bb1f0ca2766c444bd0afa9ed (patch) | |
tree | 39e4a3018f02ad11454a4d3fc43fe2300e533a78 /advtrains/trainlogic.lua | |
parent | ef21e70479d31973e47988a2246870ddc429226a (diff) | |
download | advtrains-61d0378ad6b988e6bb1f0ca2766c444bd0afa9ed.tar.gz advtrains-61d0378ad6b988e6bb1f0ca2766c444bd0afa9ed.tar.bz2 advtrains-61d0378ad6b988e6bb1f0ca2766c444bd0afa9ed.zip |
Implement Sifa; add textures for PZB
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 ]] |