diff options
author | autocommitter <autocommitter@linux-forks.de> | 2024-10-15 22:37:32 +0200 |
---|---|---|
committer | autocommitter <autocommitter@linux-forks.de> | 2024-10-15 22:37:32 +0200 |
commit | 5c7f77725394d47ce0b907aabf885ea207a507bd (patch) | |
tree | a1ff9c67ef8f225a259e4c6f4c163a45c58bb870 /durt/nodes/(1858,17,4242).lua | |
parent | b435d1b1b26db6f7c4f3eb589ecf1ed3bb79b57e (diff) | |
download | luaatc_envs-5c7f77725394d47ce0b907aabf885ea207a507bd.tar.gz luaatc_envs-5c7f77725394d47ce0b907aabf885ea207a507bd.tar.bz2 luaatc_envs-5c7f77725394d47ce0b907aabf885ea207a507bd.zip |
State at 2024-10-15
Diffstat (limited to 'durt/nodes/(1858,17,4242).lua')
-rw-r--r-- | durt/nodes/(1858,17,4242).lua | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/durt/nodes/(1858,17,4242).lua b/durt/nodes/(1858,17,4242).lua new file mode 100644 index 0000000..4f60fe8 --- /dev/null +++ b/durt/nodes/(1858,17,4242).lua @@ -0,0 +1,87 @@ +local dir = "HEAD" --indicates which part of the train leaves the station: HEAD, SHOVE +local movelist = { + SHOVE = { --loco first into platform, shove the outbound + "OAF_REV_"..dir, + "OAF_HS_N", + "OAF_SB_TK2", + "OAF_HS_S2", + "OAF_HS_S2_AC", + "OAF_NB_TK1_SHUNT", + "OAF_runaround_rejoin", + }, + HEAD = { --shoved into platform, loco first outbound + "OAF_REV_"..dir, + "OAF_HS_N", + "OAF_SB_TK3", + "OAF_HS_S", + "OAF_HS_S_AC", + "OAF_NB_TK2_SHUNT", + "OAF_runaround_rejoin", + } +} + +print("==================================") +print(dir) + +if event.train then + if not atc_arrow then + if F.has_rc("OAF_runaround_rejoin") then --loco has returned, shove through to ensure past signal IP + schedule_in(";05",atc_id) + print("SHOVE THROUGH") + return + end + return + end + if not F.has_rc("OAF_BRANCH_REVERSE") then return end + if not F.has_rc("OAF_runaround_rejoin") then + print("BEGIN") + atc_send("S0WOL") + schedule_in(";03",atc_id) --semi-realistic decoupling time + return + end + if not F.has_rc("OAF_REV_"..dir) then return end + F.remove_rc(movelist[dir]) + F.add_rc("OAF_BRANCH_REVERSE_RECOUPLED") + schedule_in(";05",atc_id) --semi-realistic recoupling time + print("REJOIN") + return +end + +if event.schedule then + print("Arrow: "..tostring(atc_arrow)) + print("ID: "..tostring(atc_id)) + print("msg: "..tostring(event.msg)) + if atc_id and atc_id ~= event.msg then return end --somehow another train snuck in??? or we've coupled weird over the track + if not atc_id then --loco has returned, should have already coupled and shoved through as buffers would have been over track to begin with + atc_send_to_train(event.msg,"B0WRD1A1S1") + return + end + if not F.has_rc("OAF_BRANCH_REVERSE") then return end --probably not our train anyway ??? + + if dir == "HEAD" and atc_arrow ~= true then --!!!!!! previously managed to get valid atc_id and arrow == nil when using (atc_arrow == false) + schedule_in(";01", atc_id) --keep clock going to ensure rejoining loco has coupled + print("CLOCK") + return + end + + if not F.has_rc("OAF_BRANCH_REVERSE_RECOUPLED") then + if dir == "SHOVE" then -- loco first into platform, run around to shove out + -- split_off_locomotive("S0OLA0",2) --ideally each pax wagon has a generic FC, but not likely as few people use them at all + split_at_index(2,"S0OLA0") + atc_send("S3") + F.add_rc(movelist[dir]) + else --dir == "HEAD" --shoved into platform, run around to put loco first + F.add_rc(movelist[dir]) + split_at_index(train_length(),"S0WRA1S3") + F.remove_rc(movelist[dir]) + atc_send("S0WROR") + end + print("SPLIT") + return + end + F.remove_rc("OAF_BRANCH_REVERSE_RECOUPLED") + F.add_rc("OAF_BRANCH_REVERSE_DONE") --triggers the ARS to depart + atc_send("SM") + print("DEPARTING") + return +end
\ No newline at end of file |