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/(-4152,13,-5840).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/(-4152,13,-5840).lua')
-rw-r--r-- | durt/nodes/(-4152,13,-5840).lua | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/durt/nodes/(-4152,13,-5840).lua b/durt/nodes/(-4152,13,-5840).lua new file mode 100644 index 0000000..2611c48 --- /dev/null +++ b/durt/nodes/(-4152,13,-5840).lua @@ -0,0 +1,84 @@ +--[[Road Loco Storage]]-- +local departures_indicator = POS(-4107, 20, -5791) +local departures_busy_indicator = POS(-4107, 20, -5795) +local TYARD_notify_indicator = POS(-4107, 20, -5789) + +local notification_id = "DLG" +local print_notification = true + +local function send_train() + local cmd = { -- base RC to collect from TYARD + "FREIGHT", + "DLG_FREIGHT", + "M27", + "TYARD", + "TY_RTS", + "TY_COLLECT_DLG", + } + + if F.indicator(departures_indicator) then + --departures available, if not busy then collect departures + if F.indicator(departures_busy_indicator) then + -- shunter still on departures track. wait a bit and check again + schedule_in("1;0","check_again") + return false + end + --actually send train via departures track + --departures track will disable departures_indicator + cmd[#cmd+1] = "DLG_HS_N" + cmd[#cmd+1] = "DLG_HS_N_AC" + cmd[#cmd+1] = "DLG_COLLECT_DEPARTURES" + cmd[#cmd+1] = "DLG_Departures_REV_S" + set_rc(table.concat(cmd," ")) + atc_send("S0WRD2A1S4") + return true + end + --no departures to collect, go straight to TYARD + set_rc(table.concat(cmd," ")) + atc_send("S0WRD2A1S4") + F.indicator(TYARD_notify_indicator,false) + return true +end + +if event.schedule then + if event.message == "check_again" then + if not send_train() then --will either send train or continue clock + schedule_in("1;0","check_again") + return + end + end +end + +if event.ext_int then + if event.message == "departures" or event.message == "manual" then + if print_notification then print(rwt.to_string(rwt.now()).. " "..notification_id.." RX Notification - "..event.message) end + if atc_id then + send_train() + else + F.indicator(departures_indicator,true) + end + return + end + + if event.message == "notify" then + if print_notification then print(rwt.to_string(rwt.now()).. " "..notification_id.." RX Notification - notify") end + if F.indicator(TYARD_notify_indicator) then return end + if atc_id then + send_train() + else + F.indicator(TYARD_notify_indicator,true) + end + return + end +end + +if event.train then + if F.indicator(TYARD_notify_indicator) or F.indicator(departures_indicator) then + print("DLG loco returned. Servicing loco before next departure") + atc_send("B0") + schedule_in("2;0","start_checking") + return + end + atc_send("B0") + return +end
\ No newline at end of file |