--[[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