1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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
|