diff options
author | autocommitter <autocommitter@linux-forks.de> | 2024-04-22 14:56:58 +0200 |
---|---|---|
committer | autocommitter <autocommitter@linux-forks.de> | 2024-04-22 14:56:58 +0200 |
commit | 4590cc6504d625404f0af394da41bb71fc2dec45 (patch) | |
tree | bc8ae688454d7254909feb05e87d46fb4241bea2 | |
parent | aeea70df13db7d77ce2ce1075cbd14dc1c3797fc (diff) | |
download | luaatc_envs-4590cc6504d625404f0af394da41bb71fc2dec45.tar.gz luaatc_envs-4590cc6504d625404f0af394da41bb71fc2dec45.tar.bz2 luaatc_envs-4590cc6504d625404f0af394da41bb71fc2dec45.zip |
State at 2022-04-20
-rw-r--r-- | Tyard/init_code.lua | 10 | ||||
-rw-r--r-- | Tyard/nodes/(-3967,12,-2646).lua | 1 | ||||
-rw-r--r-- | Tyard/nodes/(-4011,12,-2642).lua | 1 | ||||
-rw-r--r-- | Tyard/nodes/(-4012,12,-2646).lua | 46 | ||||
-rw-r--r-- | Tyard/nodes/(-4027,12,-2655).lua | 30 | ||||
-rw-r--r-- | Tyard/nodes/(-4027,12,-2731).lua | 30 | ||||
-rw-r--r-- | Tyard/nodes/(-4031,12,-2655).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4031,12,-2731).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4035,12,-2655).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4035,12,-2731).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4039,12,-2655).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4039,12,-2731).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4043,12,-2655).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4043,12,-2731).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4047,12,-2655).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4047,12,-2731).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4051,12,-2655).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4051,12,-2731).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4055,12,-2655).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4055,12,-2731).lua | 31 | ||||
-rw-r--r-- | Tyard/nodes/(-4100,12,-2742).lua | 45 | ||||
-rw-r--r-- | Tyard/nodes/(-4167,12,-2742).lua | 1 |
22 files changed, 556 insertions, 42 deletions
diff --git a/Tyard/init_code.lua b/Tyard/init_code.lua index a90efdf..9199f26 100644 --- a/Tyard/init_code.lua +++ b/Tyard/init_code.lua @@ -1,4 +1,12 @@ --Environment Code +F.error = function(set) + local error_indicator = POS(-4025,13,-2671) + if set ~= nil then + setstate(error_indicator,(set and "on") or "off") + end + return (getstate(error_indicator) == "on") or false +end + F.yard_active = function(set) --if set == true then yard = active local yard_indicator = POS(-4025,14,-2659) if set ~= nil then @@ -19,7 +27,7 @@ F.get_rc_safe = function() return get_rc() or "" end -F.has_rc = function(query,rc_list) +F.has_rc = function(query,rc_list) -- query eg: "rc1" if rc_list == "" or query == nil or query=="" then return false end if not rc_list then rc_list = F.get_rc_safe() end for word in rc_list:gmatch("[^%s]+") do diff --git a/Tyard/nodes/(-3967,12,-2646).lua b/Tyard/nodes/(-3967,12,-2646).lua new file mode 100644 index 0000000..341efa9 --- /dev/null +++ b/Tyard/nodes/(-3967,12,-2646).lua @@ -0,0 +1 @@ +-- Headshunt Exit Controller
\ No newline at end of file diff --git a/Tyard/nodes/(-4011,12,-2642).lua b/Tyard/nodes/(-4011,12,-2642).lua index d263812..56b9414 100644 --- a/Tyard/nodes/(-4011,12,-2642).lua +++ b/Tyard/nodes/(-4011,12,-2642).lua @@ -1,4 +1,5 @@ -- Yard arrival checker +-- F.dir = true if entering from south local function enter_yard() F.dir(false) F.yard_active(true) diff --git a/Tyard/nodes/(-4012,12,-2646).lua b/Tyard/nodes/(-4012,12,-2646).lua index 5199847..751506b 100644 --- a/Tyard/nodes/(-4012,12,-2646).lua +++ b/Tyard/nodes/(-4012,12,-2646).lua @@ -1 +1,45 @@ --- Headshunt / Exit controller
\ No newline at end of file +-- Headshunt Controller +-- Note: may need customising due to track layout +local this_dir = true -- true = F.dir arrow points north. atc_arrow points towards yard +local error_indicator = POS(-4025,13,-2671) +__approach_callback_mode = 1 +if event.approach and not event.has_entered then + atc_set_ars_disable(true) + atc_set_lzb_tsr(1) + return +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 + else --train has bounced + if F.has_rc("TY_AROUND") then + if this_dir = F.dir() then --send train to Classification + F.remove_rc({"TY_AROUND"}) + F.add_rc({"TY_PICKUP"}) + atc_set_ars_disable(false) + return + 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 + end + return +end + +if event.schedule then + if not atc_id then --bounce the train that just passed + atc_send_to_train(event.msg,"S0WRD1S3") + else + if atc_id == event.msg then --train hasn't fully passed yet, wait a bit longer + schedule_in(";01",atc_id) + else -- somehow another train crossed the controller before the first one returned. Unlikely but possible + atc_send_to_train(event.msg,"BBOL") + atc_send("BBOL") + F.error(true) + end + end + return +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4027,12,-2655).lua b/Tyard/nodes/(-4027,12,-2655).lua index 136f70b..c090df1 100644 --- a/Tyard/nodes/(-4027,12,-2655).lua +++ b/Tyard/nodes/(-4027,12,-2655).lua @@ -1,32 +1,36 @@ -- Classification track -local this_dir = true -- true = F.dir arrow points north +local this_dir = true -- F.dir arrow points north then this is true if F.yard_active() then - if atc_arrow then -- train is at working end - if F.has_rc("TY_arrive") then --first pass + 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","TY_WYE"}) --need to add direction selection in the southern headshunt controller + 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() + 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 --> local remove = {} for v in F.get_rc_safe():gmatch("(TY_CLASS_*)") do table.insert(remove,v) end F.remove_rc(remove) - atc_set_ars_disable(false) - else - F.add_rc({"TY_DEPART"}) - atc_set_ars_disable(false) - --send train to collect relevant wagon group and depart + 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 + atc_set_ars_disable(false) else --bounce train back towards working end - atc_send("S0WRD1S3") + 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 diff --git a/Tyard/nodes/(-4027,12,-2731).lua b/Tyard/nodes/(-4027,12,-2731).lua index 2b91223..30321c2 100644 --- a/Tyard/nodes/(-4027,12,-2731).lua +++ b/Tyard/nodes/(-4027,12,-2731).lua @@ -1,32 +1,36 @@ -- Classification track -local this_dir = false -- true = F.dir arrow points north +local this_dir = false -- F.dir arrow points north then this is true if F.yard_active() then - if atc_arrow then -- train is at working end - if F.has_rc("TY_arrive") then --first pass + 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","TY_WYE"}) --need to add direction selection in the southern headshunt controller + 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() + 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 --> local remove = {} for v in F.get_rc_safe():gmatch("(TY_CLASS_*)") do table.insert(remove,v) end F.remove_rc(remove) - atc_set_ars_disable(false) - else - F.add_rc({"TY_DEPART"}) - atc_set_ars_disable(false) - --send train to collect relevant wagon group and depart + 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 + atc_set_ars_disable(false) else --bounce train back towards working end - atc_send("S0WRD1S3") + 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 diff --git a/Tyard/nodes/(-4031,12,-2655).lua b/Tyard/nodes/(-4031,12,-2655).lua index 7489acc..512ce80 100644 --- a/Tyard/nodes/(-4031,12,-2655).lua +++ b/Tyard/nodes/(-4031,12,-2655).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..12b9ecf 100644 --- a/Tyard/nodes/(-4031,12,-2731).lua +++ b/Tyard/nodes/(-4031,12,-2731).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..512ce80 100644 --- a/Tyard/nodes/(-4035,12,-2655).lua +++ b/Tyard/nodes/(-4035,12,-2655).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..12b9ecf 100644 --- a/Tyard/nodes/(-4035,12,-2731).lua +++ b/Tyard/nodes/(-4035,12,-2731).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..512ce80 100644 --- a/Tyard/nodes/(-4039,12,-2655).lua +++ b/Tyard/nodes/(-4039,12,-2655).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..12b9ecf 100644 --- a/Tyard/nodes/(-4039,12,-2731).lua +++ b/Tyard/nodes/(-4039,12,-2731).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..512ce80 100644 --- a/Tyard/nodes/(-4043,12,-2655).lua +++ b/Tyard/nodes/(-4043,12,-2655).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..12b9ecf 100644 --- a/Tyard/nodes/(-4043,12,-2731).lua +++ b/Tyard/nodes/(-4043,12,-2731).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..512ce80 100644 --- a/Tyard/nodes/(-4047,12,-2655).lua +++ b/Tyard/nodes/(-4047,12,-2655).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..12b9ecf 100644 --- a/Tyard/nodes/(-4047,12,-2731).lua +++ b/Tyard/nodes/(-4047,12,-2731).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..512ce80 100644 --- a/Tyard/nodes/(-4051,12,-2655).lua +++ b/Tyard/nodes/(-4051,12,-2655).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..12b9ecf 100644 --- a/Tyard/nodes/(-4051,12,-2731).lua +++ b/Tyard/nodes/(-4051,12,-2731).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..512ce80 100644 --- a/Tyard/nodes/(-4055,12,-2655).lua +++ b/Tyard/nodes/(-4055,12,-2655).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = true -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + 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 7489acc..12b9ecf 100644 --- a/Tyard/nodes/(-4055,12,-2731).lua +++ b/Tyard/nodes/(-4055,12,-2731).lua @@ -1 +1,30 @@ ---
\ No newline at end of file +--EOL code +local this_dir = false -- true = F.dir arrow points north +local error_indicator = POS(-4025,13,-2671) +if F.yard_active() then + 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 + 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 + setstate(error_indicator,"on") + end + end +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4100,12,-2742).lua b/Tyard/nodes/(-4100,12,-2742).lua new file mode 100644 index 0000000..1917d7f --- /dev/null +++ b/Tyard/nodes/(-4100,12,-2742).lua @@ -0,0 +1,45 @@ +-- Headshunt Controller +-- Note: may need customising due to track layout +local this_dir = false -- true = F.dir arrow points north. atc_arrow points towards yard +local error_indicator = POS(-4025,13,-2671) +__approach_callback_mode = 1 +if event.approach and not event.has_entered then + atc_set_ars_disable(true) + atc_set_lzb_tsr(1) + return +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 + else --train has bounced + if F.has_rc("TY_AROUND") then + if this_dir = F.dir() then --send train to Classification + F.remove_rc({"TY_AROUND"}) + F.add_rc({"TY_PICKUP"}) + atc_set_ars_disable(false) + return + 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 + end + return +end + +if event.schedule then + if not atc_id then --bounce the train that just passed + atc_send_to_train(event.msg,"S0WRD1S3") + else + if atc_id == event.msg then --train hasn't fully passed yet, wait a bit longer + schedule_in(";01",atc_id) + else -- somehow another train crossed the controller before the first one returned. Unlikely but possible + atc_send_to_train(event.msg,"BBOL") + atc_send("BBOL") + F.error(true) + end + end + return +end
\ No newline at end of file diff --git a/Tyard/nodes/(-4167,12,-2742).lua b/Tyard/nodes/(-4167,12,-2742).lua new file mode 100644 index 0000000..341efa9 --- /dev/null +++ b/Tyard/nodes/(-4167,12,-2742).lua @@ -0,0 +1 @@ +-- Headshunt Exit Controller
\ No newline at end of file |