summaryrefslogtreecommitdiff
path: root/Tyard/nodes/(-3967,12,-2646).lua
blob: bf0099df861cdc8404b5ecd0b1c4280f9e277011 (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
-- Headshunt Exit Controller
local exit_signal = POS(-3962,14,-2645)

if not F.yard_active() then return end
__approach_callback_mode = 1
if event.approach and not event.has_entered then
	atc_set_ars_disable(true)
	atc_set_lzb_tsr(1)
	return
end

if event.train then
	if atc_arrow then
		if F.has_rc("TY_DEPART") then
			print("Train departs yard to mainline at full speed")
			unset_autocouple()
			F.remove_rc({"TY_FINAL_COLLECT","TY_DEPART"})
			F.remove_rc_match("TY_LOCOS_%d+")
			F.remove_rc_match("TY_WAGONS_%d+")
			atc_set_ars_disable(false)
			set_route(exit_signal,"Exit Yard")
			atc_send("S6D10SM")
			schedule_in(";05","deactivate_check") -- wait a little to ensure train is clear from headshunt to deactivate yard
			print(F.get_rc_safe())
			return
		end
	else
		atc_send("BBOL")
		F.error(true)
	end
end

if event.schedule then
	if event.msg == "deactivate_check" then
		if not atc_id then
			F.yard_active(false)
			print("Yard Disabled")
		else
			schedule_in(";05","deactivate_check")
			return
		end
	end
end