diff options
Diffstat (limited to 'Tyard')
-rw-r--r-- | Tyard/init_code.lua | 46 | ||||
-rw-r--r-- | Tyard/nodes/(-4012,12,-2646).lua | 23 | ||||
-rw-r--r-- | Tyard/nodes/(-4027,12,-2655).lua | 47 | ||||
-rw-r--r-- | Tyard/nodes/(-4027,12,-2731).lua | 47 | ||||
-rw-r--r-- | Tyard/nodes/(-4031,12,-2655).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4031,12,-2731).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4035,12,-2655).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4035,12,-2731).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4039,12,-2655).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4039,12,-2731).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4043,12,-2655).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4043,12,-2731).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4047,12,-2655).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4047,12,-2731).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4051,12,-2655).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4051,12,-2731).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4055,12,-2655).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4055,12,-2731).lua | 29 | ||||
-rw-r--r-- | Tyard/nodes/(-4100,12,-2742).lua | 23 |
19 files changed, 497 insertions, 95 deletions
diff --git a/Tyard/init_code.lua b/Tyard/init_code.lua index 9b21432..fe220da 100644 --- a/Tyard/init_code.lua +++ b/Tyard/init_code.lua @@ -33,6 +33,7 @@ F.has_rc = function(query,rc_list) -- query eg: "rc1" for word in rc_list:gmatch("[^%s]+") do if word == query then return true end end + print(F.get_rc_safe()) return false end @@ -62,47 +63,26 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list eg: {"rc1","rc2"} -- insert new string to train's rc set_rc(table.concat(reinsert," ")) end + print(F.get_rc_safe()) return reinsert end +F.remove_rc_match = function(rc_list) -- rc_list eg: "rc_%d+" + local rm = {} + for v in F.get_rc_safe():gmatch("("..rc_list..")") do + table.insert(rm,v) + end + F.remove_rc(rm) + print(F.get_rc_safe()) + return rm +end + F.add_rc = function(rc_list) -- rc_list eg {"rc1","rc2"} OR "rc1 rc2" if not atc_id then return false end if type(rc_list) == "table" then rc_list = table.concat(rc_list," ") end set_rc(F.get_rc_safe().." "..rc_list) + print(F.get_rc_safe()) return true end - --- EOL function -F.EOL = function(this_dir) - -- this_dir == true for north end, false for south end - if not F.yard_active() then return end - if atc_arrow then - if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it - if F.has_rc("TY_FINAL_COLLECT") then -- take the whole rake to the exit - F.remove({"TY_FINAL_COLLECT"}) - F.add_rc({"TY_DEPART"}) - else -- disconnect loco and return to pickup - split_off_locomotive("A0B0") - F.add_rc({"TY_PICKUP"}) - end - F.add_rc({"TY_HEADSHUNT"}) - else --train needs to bounce - atc_send("B0WRD1S4") - end - else - if F.dir() == this_dir then - --train is clasifying wagons, let it pass and couple to the rest of the rake - local rm = {} - for v in F.get_rc_safe():gmatch("(TY_CLASS_%S-)") do - table.insert(rm,v) - end - F.remove_rc(rm) - else --this should never come into play as it means the train has entered from the wrong end somehow - atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required - F.error(true) - end - end -end - diff --git a/Tyard/nodes/(-4012,12,-2646).lua b/Tyard/nodes/(-4012,12,-2646).lua index aa2cbfe..670bb6c 100644 --- a/Tyard/nodes/(-4012,12,-2646).lua +++ b/Tyard/nodes/(-4012,12,-2646).lua @@ -13,11 +13,23 @@ end if event.train then if not atc_arrow then --train has entered headshunt from yard. bounce or depart - if not F.has_rc("TY_DEPART") then --if has TY_DEPART then another controller closer to the signal will remove to ensure signal engages the RC - schedule_in(";01",atc_id) - atc_set_ars_disable(true) - return - end + atc_set_ars_disable(true) + F.remove_rc({"TY_HEADSHUNT"}) + if not F.has_rc("TY_FINAL_COLLECT") then + if not F.has_rc("TY_DEPART") then + schedule_in(";01",atc_id) + return + else + local collect = F.get_rc_safe():match("TY_COLLECT_(%S+)") + if collect then --train needs to collect a rake from the yard before departing + F.add_rc({"TY_FINAL_COLLECT","TY_CLASS_"..collect}) + schedule_in(";01",atc_id) + return + end + end + + --else let train proceed forward to the exit controller without a rake + end --else train has already collected rake. let it exit yard else --train has bounced if F.has_rc("TY_AROUND") then if this_dir == F.dir() then --send train to Classification @@ -28,7 +40,6 @@ if event.train then end --if at wrong end, do nothing. train will follow TY_AROUND ARS to relevant headshunt end -- if doesn't have TY_AROUND then let ARS classify the train - F.remove_rc({"TY_HEADSHUNT"}) atc_set_ars_disable(false) end return diff --git a/Tyard/nodes/(-4027,12,-2655).lua b/Tyard/nodes/(-4027,12,-2655).lua index 5634403..b7ed9c7 100644 --- a/Tyard/nodes/(-4027,12,-2655).lua +++ b/Tyard/nodes/(-4027,12,-2655).lua @@ -4,40 +4,51 @@ local this_dir = 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_ARRIVE") and F.dir() == this_dir then --first pass, prep train for working F.remove_rc({"TY_AROUND"}) + if not F.get_rc_safe():match("TY_LOCOS_%d+") or not F.get_rc_safe():match("TY_WAGONS_%d+") then + local full_length = train_length() + split_off_locomotive("A0B0") + F.add_rc({"TY_HEADSHUNT"}) -- train will end up going through headshunt no matter what. there shouldn't be any trains entering that pass straight through. + if train_length() == full_length then --train is either only here for collection or there's no FC's in the wagons. can't differentiate + local lane = F.get_rc_safe():match("TY_COLLECT_(%S+)") or "" + F.add_rc({"TY_LAST_CLASS","TY_CLASS_"..lane}) -- direct train to correct lane for collection + else --identify and save loco:wagon ratio, then bounce back from headshunt. it's easier than trying to reconnect + F.add_rc({"TY_LOCOS_"..train_length(), "TY_WAGONS_"..(full_length-train_length()),"TY_PICKUP"}) + end + return -- train has departed for headshunt + end if F.has_rc("TY_RTS") then F.dir(not F.dir()) F.remove_rc({"TY_RTS"}) F.add_rc({"TY_HEADSHUNT","TY_AROUND"}) -- send loco around to the other end split_off_locomotive("A0B0") atc_set_ars_disable(false) - return + return -- train has departed for RTS loop 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 - if not F.has_rc("TY_LAST_CLASS") then - F.add_rc({"TY_CLASS_"..lane,"TY_LAST_CLASS"}) - else - 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 + -- local pre_split = train_length() + local lane = split_at_fc("A0B0",3) -- where to classify this rake + local locos = tonumber(F.get_rc_safe():match("TY_LOCOS_(%d+)")) or 1 --saved loco count + local wagons = tonumber(F.get_rc_safe():match("TY_WAGONS_(%d+)")) or 0 -- wagon_count from last classification split + local this_rake = train_length() - locos-- subtract these wagons from the overall wagon count + if this_rake == wagons then -- mark for last_classification + F.add_rc({"TY_LAST_CLASS"}) + end + if lane ~= "" then + F.add_rc({"TY_CLASS_"..lane}) + end + for v in F.get_rc_safe():gmatch("(TY_WAGONS_%d+)") do + F.remove_rc({v}) end - F.add_rc({"TY_HEADSHUNT"}) + F.add_rc({"TY_HEADSHUNT","TY_WAGONS_"..wagons-this_rake}) atc_set_ars_disable(false) set_autocouple() else --bounce train back towards working end + atc_set_ars_disable(true) atc_send("S0WRD1S3") unset_autocouple() end diff --git a/Tyard/nodes/(-4027,12,-2731).lua b/Tyard/nodes/(-4027,12,-2731).lua index e703257..836ebf8 100644 --- a/Tyard/nodes/(-4027,12,-2731).lua +++ b/Tyard/nodes/(-4027,12,-2731).lua @@ -4,40 +4,51 @@ local this_dir = false 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_ARRIVE") and F.dir() == this_dir then --first pass, prep train for working F.remove_rc({"TY_AROUND"}) + if not F.get_rc_safe():match("TY_LOCOS_%d+") or not F.get_rc_safe():match("TY_WAGONS_%d+") then + local full_length = train_length() + split_off_locomotive("A0B0") + F.add_rc({"TY_HEADSHUNT"}) -- train will end up going through headshunt no matter what. there shouldn't be any trains entering that pass straight through. + if train_length() == full_length then --train is either only here for collection or there's no FC's in the wagons. can't differentiate + local lane = F.get_rc_safe():match("TY_COLLECT_(%S+)") or "" + F.add_rc({"TY_LAST_CLASS","TY_CLASS_"..lane}) -- direct train to correct lane for collection + else --identify and save loco:wagon ratio, then bounce back from headshunt. it's easier than trying to reconnect + F.add_rc({"TY_LOCOS_"..train_length(), "TY_WAGONS_"..(full_length-train_length()),"TY_PICKUP"}) + end + return -- train has departed for headshunt + end if F.has_rc("TY_RTS") then F.dir(not F.dir()) F.remove_rc({"TY_RTS"}) F.add_rc({"TY_HEADSHUNT","TY_AROUND"}) -- send loco around to the other end split_off_locomotive("A0B0") atc_set_ars_disable(false) - return + return -- train has departed for RTS loop 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 - if not F.has_rc("TY_LAST_CLASS") then - F.add_rc({"TY_CLASS_"..lane,"TY_LAST_CLASS"}) - else - 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 + -- local pre_split = train_length() + local lane = split_at_fc("A0B0",3) -- where to classify this rake + local locos = tonumber(F.get_rc_safe():match("TY_LOCOS_(%d+)")) or 1 --saved loco count + local wagons = tonumber(F.get_rc_safe():match("TY_WAGONS_(%d+)")) or 0 -- wagon_count from last classification split + local this_rake = train_length() - locos-- subtract these wagons from the overall wagon count + if this_rake == wagons then -- mark for last_classification + F.add_rc({"TY_LAST_CLASS"}) + end + if lane ~= "" then + F.add_rc({"TY_CLASS_"..lane}) + end + for v in F.get_rc_safe():gmatch("(TY_WAGONS_%d+)") do + F.remove_rc({v}) end - F.add_rc({"TY_HEADSHUNT"}) + F.add_rc({"TY_HEADSHUNT","TY_WAGONS_"..wagons-this_rake}) atc_set_ars_disable(false) set_autocouple() else --bounce train back towards working end + atc_set_ars_disable(true) atc_send("S0WRD1S3") unset_autocouple() end diff --git a/Tyard/nodes/(-4031,12,-2655).lua b/Tyard/nodes/(-4031,12,-2655).lua index 747fb3d..f08c2fe 100644 --- a/Tyard/nodes/(-4031,12,-2655).lua +++ b/Tyard/nodes/(-4031,12,-2655).lua @@ -1 +1,28 @@ -F.EOL(true)
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4031,12,-2731).lua b/Tyard/nodes/(-4031,12,-2731).lua index b8358f2..aad7649 100644 --- a/Tyard/nodes/(-4031,12,-2731).lua +++ b/Tyard/nodes/(-4031,12,-2731).lua @@ -1 +1,28 @@ -F.EOL(false)
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4035,12,-2655).lua b/Tyard/nodes/(-4035,12,-2655).lua index 747fb3d..f08c2fe 100644 --- a/Tyard/nodes/(-4035,12,-2655).lua +++ b/Tyard/nodes/(-4035,12,-2655).lua @@ -1 +1,28 @@ -F.EOL(true)
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4035,12,-2731).lua b/Tyard/nodes/(-4035,12,-2731).lua index b8358f2..aad7649 100644 --- a/Tyard/nodes/(-4035,12,-2731).lua +++ b/Tyard/nodes/(-4035,12,-2731).lua @@ -1 +1,28 @@ -F.EOL(false)
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4039,12,-2655).lua b/Tyard/nodes/(-4039,12,-2655).lua index 747fb3d..f08c2fe 100644 --- a/Tyard/nodes/(-4039,12,-2655).lua +++ b/Tyard/nodes/(-4039,12,-2655).lua @@ -1 +1,28 @@ -F.EOL(true)
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4039,12,-2731).lua b/Tyard/nodes/(-4039,12,-2731).lua index b8358f2..aad7649 100644 --- a/Tyard/nodes/(-4039,12,-2731).lua +++ b/Tyard/nodes/(-4039,12,-2731).lua @@ -1 +1,28 @@ -F.EOL(false)
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4043,12,-2655).lua b/Tyard/nodes/(-4043,12,-2655).lua index 747fb3d..f08c2fe 100644 --- a/Tyard/nodes/(-4043,12,-2655).lua +++ b/Tyard/nodes/(-4043,12,-2655).lua @@ -1 +1,28 @@ -F.EOL(true)
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4043,12,-2731).lua b/Tyard/nodes/(-4043,12,-2731).lua index b8358f2..aad7649 100644 --- a/Tyard/nodes/(-4043,12,-2731).lua +++ b/Tyard/nodes/(-4043,12,-2731).lua @@ -1 +1,28 @@ -F.EOL(false)
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4047,12,-2655).lua b/Tyard/nodes/(-4047,12,-2655).lua index 747fb3d..f08c2fe 100644 --- a/Tyard/nodes/(-4047,12,-2655).lua +++ b/Tyard/nodes/(-4047,12,-2655).lua @@ -1 +1,28 @@ -F.EOL(true)
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4047,12,-2731).lua b/Tyard/nodes/(-4047,12,-2731).lua index b8358f2..aad7649 100644 --- a/Tyard/nodes/(-4047,12,-2731).lua +++ b/Tyard/nodes/(-4047,12,-2731).lua @@ -1 +1,28 @@ -F.EOL(false)
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4051,12,-2655).lua b/Tyard/nodes/(-4051,12,-2655).lua index 747fb3d..f08c2fe 100644 --- a/Tyard/nodes/(-4051,12,-2655).lua +++ b/Tyard/nodes/(-4051,12,-2655).lua @@ -1 +1,28 @@ -F.EOL(true)
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4051,12,-2731).lua b/Tyard/nodes/(-4051,12,-2731).lua index b8358f2..aad7649 100644 --- a/Tyard/nodes/(-4051,12,-2731).lua +++ b/Tyard/nodes/(-4051,12,-2731).lua @@ -1 +1,28 @@ -F.EOL(false)
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4055,12,-2655).lua b/Tyard/nodes/(-4055,12,-2655).lua index 747fb3d..f08c2fe 100644 --- a/Tyard/nodes/(-4055,12,-2655).lua +++ b/Tyard/nodes/(-4055,12,-2655).lua @@ -1 +1,28 @@ -F.EOL(true)
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4055,12,-2731).lua b/Tyard/nodes/(-4055,12,-2731).lua index b8358f2..aad7649 100644 --- a/Tyard/nodes/(-4055,12,-2731).lua +++ b/Tyard/nodes/(-4055,12,-2731).lua @@ -1 +1,28 @@ -F.EOL(false)
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north + +if not F.yard_active() then return end +if atc_arrow then + if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it + if F.has_rc("TY_LAST_CLASS") then -- take the whole rake to the exit + F.remove_rc({"TY_LAST_CLASS"}) + F.add_rc({"TY_DEPART"}) + split_off_locomotive("A0B0") + elseif not F.has_rc("TY_FINAL_COLLECT") then + -- disconnect loco and return to pickup + split_off_locomotive("A0B0") + F.add_rc({"TY_PICKUP"}) + end --if has FINAL_COLLECT then don't split off the loco. take the full rake + F.add_rc({"TY_HEADSHUNT"}) + else --train needs to bounce + atc_send("B0WRD1S4") + end +else + if F.dir() == this_dir then + --train is clasifying wagons, let it pass and couple to the rest of the rake + F.remove_rc_match("TY_CLASS_%S+") + else --this should never come into play as it means the train has entered from the wrong end somehow + atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required + F.error(true) + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4100,12,-2742).lua b/Tyard/nodes/(-4100,12,-2742).lua index 1fc57ae..37b303a 100644 --- a/Tyard/nodes/(-4100,12,-2742).lua +++ b/Tyard/nodes/(-4100,12,-2742).lua @@ -13,11 +13,23 @@ end if event.train then if not atc_arrow then --train has entered headshunt from yard. bounce or depart - if not F.has_rc("TY_DEPART") then --if has TY_DEPART then another controller closer to the signal will remove to ensure signal engages the RC - schedule_in(";01",atc_id) - atc_set_ars_disable(true) - return - end + atc_set_ars_disable(true) + F.remove_rc({"TY_HEADSHUNT"}) + if not F.has_rc("TY_FINAL_COLLECT") then + if not F.has_rc("TY_DEPART") then + schedule_in(";01",atc_id) + return + else + local collect = F.get_rc_safe():match("TY_COLLECT_(%S+)") + if collect then --train needs to collect a rake from the yard before departing + F.add_rc({"TY_FINAL_COLLECT","TY_CLASS_"..collect}) + schedule_in(";01",atc_id) + return + end + end + + --else let train proceed forward to the exit controller without a rake + end --else train has already collected rake. let it exit yard else --train has bounced if F.has_rc("TY_AROUND") then if this_dir == F.dir() then --send train to Classification @@ -28,7 +40,6 @@ if event.train then end --if at wrong end, do nothing. train will follow TY_AROUND ARS to relevant headshunt end -- if doesn't have TY_AROUND then let ARS classify the train - F.remove_rc({"TY_HEADSHUNT"}) atc_set_ars_disable(false) end return |