local dir = 2 local lane = 6 if S.dir == dir and atc_arrow then set_route("HYE"..lane, "HEADSHUNT") local plen = train_length() local rc = split_at_fc("B0") local trc = "HY"..rc..dir S.cars = plen - train_length() if plen == train_length() and (rc == "" or S.rc:match(trc)) and not (S.rc:match("HYREVERSE")) then S.exiting = true end if rc and rc ~= "" then set_rc("HY"..rc..dir) else set_rc(S.rc) S.reversing = false S.exiting = true end elseif S.dir == 1 and atc_arrow then if S.rc:match("HYREVERSE") and S.cars == 0 then set_route("HYE"..lane, "HEADSHUNT") S.reversing = true S.dir = 2 end if not S.reversing then atc_send("B0WD1RS4") end end