-- Classification track local this_dir = true -- F.dir arrow points north then this is true if F.yard_active() then if atc_arrow then -- loco is at working end F.remove_rc({"TY_PICKUP"}) if F.has_rc("TY_ARRIVE") then --first pass, prep train for working if F.has_rc("TY_RTS") then F.dir(not F.dir()) F.remove_rc({"TY_RTS"}) F.add_rc({"TY_AROUND"}) -- send loco around to the other end split_off_locomotive("A0B0") atc_set_ars_disable(false) return end F.remove_rc({"TY_ARRIVE"}) step_fc() end if this_dir = F.dir() then --train has bounced and is ready to classify wagon(s) local t_len = train_length() local lane = split_at_fc("A0B0",3) if t_len ~= train_length() then -- train still has wagons to classify F.add_rc({"TY_CLASS_"..lane}) -- to be pattern matched when leaving lane else -- train_length is the same as it was before it tried to split_at_fc, hence it's just the loco local collect = F.get_rc_safe():match("TY_COLLECT_(%S+)") if not collect then F.add_rc({"TY_DEPART"}) -- run engines-light to the exit, we're not collecting anything else F.add_rc({"TY_FINAL_COLLECT","TY_CLASS_"..collect}) --loco is to collect lane before departing. TY_DEPART to be set by EOL end end F.add_rc({"TY_HEADSHUNT"}) atc_set_ars_disable(false) else --bounce train back towards working end atc_send("S0WRD1S3A1") unset_autocouple() end else -- train entering from the far end. set autocouple so it pushes all the way through to the bounce set_autocouple() end end