From 5c7f77725394d47ce0b907aabf885ea207a507bd Mon Sep 17 00:00:00 2001 From: autocommitter Date: Tue, 15 Oct 2024 22:37:32 +0200 Subject: State at 2024-10-15 --- durt/nodes/(-4152,13,-5840).lua | 84 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 durt/nodes/(-4152,13,-5840).lua (limited to 'durt/nodes/(-4152,13,-5840).lua') 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 -- cgit v1.2.3