summaryrefslogtreecommitdiff
path: root/durt/nodes/(-3541,8,-2277).lua
blob: 22e5c4d5b54ba02fb98e224e2bc43d8c43530f78 (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
local dir = "east"
local split_indicators = {east=POS(-3559,9,-2282),west=POS(-3592,9,-2282)}
local loco_indicators = {east=POS(-3540,8,-2278),west=POS(-3593,8,-2277)}

local inv_dir = (dir=="east" and "west" or "east")

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

if event.train then
print(tostring(atc_arrow))
	local train_dir = F.get_rc_safe():match("Treefarm_headshunt_(%a%a%a%a)")
	if not train_dir then return end -- ignore this train completely
	if not atc_arrow then return end--nothing to do with this train yet
	
print(train_dir.." "..dir)
	if train_dir == dir then --train is matching arrow and has already bounced, split and let it pass
		if getstate(split_indicators[dir]) == "red" then --there's an error somewhere, shouldn't get to this
			print("error1")
			return
		end
		if not F.get_rc_safe():match("Treefarm_collect") then
			split_off_locomotive("A0B0",1)
			atc_send("A1S3")
		end
		F.remove_rc({"Treefarm_loading"})
		set_rc(F.get_rc_safe().." Treefarm_rejoin_"..dir)
	elseif train_dir == inv_dir then -- bounce the train
print("bounce")
		if getstate(split_indicators[inv_dir]) == "red" then --there's an error somewhere, shouldn't get to this
			print("error2")
			return
		end
		set_rc(F.get_rc_safe().." Treefarm_collect")
print(F.get_rc_safe())
		atc_reset()
		atc_send("S2D2S0WRS3")
print("do the bounce")
		return
	end
end