summaryrefslogtreecommitdiff
path: root/durt/nodes/(-2356,15,-1361).lua
blob: 993387a459e887ace05a4ef079fdcb9892c715cc (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local pts = {
	north={
		pos=POS(-2358,15,-1329),
		lined="st"
	},
	south={
		pos=POS(-2358,15,-1361),
		lined="st"
	},
}
local set_dir = function(dir)
	for _,v in pairs(pts) do
		setstate(v.pos,(dir==((true and v.lined=="st") or false) and "st" or "cr"))
	end
end

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

if event.train then
	if not F.has_rc("TANH_REV") then
		atc_set_ars_disable(false)
		return
	end
	
	if F.has_rc("TANH_REV_active") then
		if not atc_arrow then
			if F.has_rc("TANH_REV_loop") then
				F.remove_rc({"TANH_REV_loop"})
				set_dir(true)
			else
				F.add_rc("TANH_REV_loop")
				set_dir(false)
			end
			return
		end
		
		set_autocouple()
		schedule_in(";01",atc_id)
		return
	elseif F.has_rc("TANH_REV_exit") then
		atc_set_ars_disable(false)
		unset_autocouple()
		F.remove_rc({"TANH_REV_exit"})
		return
	else
		set_dir(true)
		return
	end
end

if event.schedule then
	if event.msg == atc_id then
		schedule_in(";01",atc_id)
		return
	elseif not atc_id then
		set_dir(false)
		atc_send_to_train(event.msg,"D1S0WRD1S2")
	else
		atc_send("BB")
		atc_send_to_train("BB")
		return
	end
end