summaryrefslogtreecommitdiff
path: root/durt/nodes/(1843,17,4278).lua
blob: dcfa6d46f020076d1bf2ba54750c4418b73cf404 (plain)
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
local notification_id = "OAF Logging"
local ind = POS(1845, 17, 4275)
local print_notification = true
local function send_train()
	local cmd = {
		"FREIGHT",
		"OAF_SHUNTER",
		"IYARD",
		"IP_RTS",
		"IP_COLLECT_OAF_Logging",
		"IYARD_TO_OAF"
	}
	if section_occupancy("186232")[1] then --wagons to collect from local siding before departure
		cmd[#cmd+1] = "OAF_HS_S"
		cmd[#cmd+1] = "OAF_HS_S_AC"
		cmd[#cmd+1] = "OAF_COLLECT_OUTBOUND"
	else
		cmd[#cmd+1] = "OAF_DEPART_LIGHT"
	end

	set_rc(table.concat(cmd, " "))
	atc_send("S0WRD2A1S4D20SM")
	F.indicator(ind,false)
end

__approach_callback_mode = 1

if event.approach and not event.has_entered then
	atc_set_lzb_tsr(1)
	return
end

if event.ext_int then
	if event.message == "notify" then
		if print_notification then print(rwt.to_string(rwt.now()).. " "..notification_id.." RX Notification") end
		if F.indicator(ind) then return end
		if atc_id then
			send_train()
			return
		else
			F.indicator(ind,true)
			return
		end
	end
end

if event.train then
	if F.indicator(ind) then
		send_train()
		return
	end
	atc_send("B0")
	return
end