local dir = "east" local split_indicators = {['east']=POS(-3539,9,-2282),['west']=POS(-3592,9,-2282)} local inv_dir = (dir=="east" and "west" or "east") __approach_callback_mode = 2 if event.approach and not event.has_entered then if not F.get_rc_safe():match("logging_pickup") then return end atc_set_ars_disable(true) atc_set_lzb_tsr(1) end if event.train then print(F.get_rc_safe()) if not F.get_rc_safe():match("logging_pickup") then return end if getstate(split_indicators[inv_dir]) == "green" then return end -- train is busy from the other end. ignore for now print(1) if atc_arrow == true then print(2) local state = getstate(split_indicators[dir]) print("state " ..tostring(state)) print(3) if state == "red" then local split_length = F.get_rc_safe():match("logging_split(%d+)") or 0 print("split length: "..split_length) split_at_index(split_length+2,"A0B0") set_rc(F.get_rc_safe().." Treefarm_headshunt_"..dir.." Treefarm_loading") atc_send("S3") atc_set_ars_disable(false) setstate(split_indicators[dir],"green") elseif state == "green" then atc_send("S5D10SM") setstate(split_indicators[dir],"red") F.remove_rc({"Treefarm_headshunt_"..dir,"Treefarm_loading","Treefarm_rejoin_"..dir,"Treefarm_collect"}) end else if F.get_rc_safe():match("Treefarm_rejoin_"..dir) then atc_set_ars_disable(true) schedule_in(";01",atc_id) return end end end if event.schedule then if event.msg == atc_id then schedule_in(";01",event.msg) return else atc_send_to_train(event.msg,"B0WRA1S3") return end end