From aeea70df13db7d77ce2ce1075cbd14dc1c3797fc Mon Sep 17 00:00:00 2001 From: autocommitter Date: Mon, 22 Apr 2024 14:56:58 +0200 Subject: State at 2022-04-19 --- Tyard/init_code.lua | 68 ++++++++++++++++++++++++++++++++++++++-- Tyard/nodes/(-4011,12,-2642).lua | 34 +++++++++++++++++++- Tyard/nodes/(-4011,12,-2647).lua | 1 + Tyard/nodes/(-4012,12,-2646).lua | 1 + Tyard/nodes/(-4027,12,-2655).lua | 36 ++++++++++++++++++++- Tyard/nodes/(-4027,12,-2731).lua | 36 ++++++++++++++++++++- Tyard/nodes/(-4028,12,-2655).lua | 1 + Tyard/nodes/(-4028,12,-2731).lua | 1 + Tyard/nodes/(-4031,12,-2655).lua | 2 +- Tyard/nodes/(-4031,12,-2731).lua | 2 +- Tyard/nodes/(-4032,12,-2655).lua | 1 + Tyard/nodes/(-4032,12,-2731).lua | 1 + Tyard/nodes/(-4035,12,-2655).lua | 2 +- Tyard/nodes/(-4035,12,-2731).lua | 2 +- Tyard/nodes/(-4036,12,-2655).lua | 1 + Tyard/nodes/(-4036,12,-2731).lua | 1 + Tyard/nodes/(-4039,12,-2655).lua | 2 +- Tyard/nodes/(-4039,12,-2731).lua | 2 +- Tyard/nodes/(-4040,12,-2655).lua | 1 + Tyard/nodes/(-4040,12,-2731).lua | 1 + Tyard/nodes/(-4043,12,-2655).lua | 2 +- Tyard/nodes/(-4043,12,-2731).lua | 2 +- Tyard/nodes/(-4044,12,-2655).lua | 1 + Tyard/nodes/(-4044,12,-2731).lua | 1 + Tyard/nodes/(-4047,12,-2655).lua | 2 +- Tyard/nodes/(-4047,12,-2731).lua | 2 +- Tyard/nodes/(-4048,12,-2655).lua | 1 + Tyard/nodes/(-4048,12,-2731).lua | 1 + Tyard/nodes/(-4051,12,-2655).lua | 2 +- Tyard/nodes/(-4051,12,-2731).lua | 2 +- Tyard/nodes/(-4052,12,-2655).lua | 1 + Tyard/nodes/(-4052,12,-2731).lua | 1 + Tyard/nodes/(-4055,12,-2655).lua | 2 +- Tyard/nodes/(-4055,12,-2731).lua | 2 +- Tyard/nodes/(-4056,12,-2655).lua | 1 + Tyard/nodes/(-4056,12,-2731).lua | 1 + Tyard/nodes/(-4100,12,-2745).lua | 33 +++++++++++++++++++ durt/nodes/(-3524,8,-2281).lua | 3 +- durt/nodes/(-3541,8,-2276).lua | 43 +++++++++++++++++++++++++ durt/nodes/(-3543,8,-2281).lua | 57 +-------------------------------- durt/nodes/(-3543,8,-2282).lua | 56 +++++++++++++++++++++++++++++++++ durt/nodes/(-3590,8,-2277).lua | 44 +------------------------- durt/nodes/(-3591,8,-2276).lua | 43 +++++++++++++++++++++++++ durt/nodes/(-3591,8,-2281).lua | 57 +-------------------------------- durt/nodes/(-3591,8,-2282).lua | 56 +++++++++++++++++++++++++++++++++ 45 files changed, 435 insertions(+), 177 deletions(-) create mode 100644 Tyard/nodes/(-4011,12,-2647).lua create mode 100644 Tyard/nodes/(-4012,12,-2646).lua create mode 100644 Tyard/nodes/(-4028,12,-2655).lua create mode 100644 Tyard/nodes/(-4028,12,-2731).lua create mode 100644 Tyard/nodes/(-4032,12,-2655).lua create mode 100644 Tyard/nodes/(-4032,12,-2731).lua create mode 100644 Tyard/nodes/(-4036,12,-2655).lua create mode 100644 Tyard/nodes/(-4036,12,-2731).lua create mode 100644 Tyard/nodes/(-4040,12,-2655).lua create mode 100644 Tyard/nodes/(-4040,12,-2731).lua create mode 100644 Tyard/nodes/(-4044,12,-2655).lua create mode 100644 Tyard/nodes/(-4044,12,-2731).lua create mode 100644 Tyard/nodes/(-4048,12,-2655).lua create mode 100644 Tyard/nodes/(-4048,12,-2731).lua create mode 100644 Tyard/nodes/(-4052,12,-2655).lua create mode 100644 Tyard/nodes/(-4052,12,-2731).lua create mode 100644 Tyard/nodes/(-4056,12,-2655).lua create mode 100644 Tyard/nodes/(-4056,12,-2731).lua create mode 100644 Tyard/nodes/(-4100,12,-2745).lua create mode 100644 durt/nodes/(-3541,8,-2276).lua create mode 100644 durt/nodes/(-3543,8,-2282).lua create mode 100644 durt/nodes/(-3591,8,-2276).lua create mode 100644 durt/nodes/(-3591,8,-2282).lua diff --git a/Tyard/init_code.lua b/Tyard/init_code.lua index 99b63e4..a90efdf 100644 --- a/Tyard/init_code.lua +++ b/Tyard/init_code.lua @@ -1,5 +1,67 @@ --- flag to hard enable RTS: -S.single_dir = true +--Environment Code +F.yard_active = function(set) --if set == true then yard = active + local yard_indicator = POS(-4025,14,-2659) + if set ~= nil then + setstate(yard_indicator,(set and "on") or "off") + end + return (getstate(yard_indicator) == "on") or false +end +F.dir = function(set) -- if set == true then dir = pointing north + local dir_indicator = POS(-4025,13,-2665) + if set ~= nil then + setstate(dir_indicator,(set and "on") or "off") + end + return (getstate(dir_indicator) == "on") or false +end -F.EOL = function(direction,lane) if S.yard_active then if S.dir == direction then if atc_arrow then if not S.exiting then --return to PICKUP via headshunt split_off_locomotive("B0WR") set_rc("PICKUP") set_route("TY"..direction.."_"..lane, "HEADSHUNT") else --if S.exiting then loco has already sorted to correct lane for departure --S.exiting set by the pickup track set_rc(S.rc) set_route("TY"..direction.."_"..lane, "EXIT") S.exiting = nil end end else -- preparing for bi-directional. also EOL Bounce atc_send("B0WD1RS4") end end end \ No newline at end of file +F.get_rc_safe = function() + return get_rc() or "" +end + +F.has_rc = function(query,rc_list) + 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 + if word == query then return true end + end + return false +end + +F.remove_rc = function(rc_list,arrow_mode) -- rc_list eg: {"rc1","rc2"} + -- rc_list MUST be a table of rc codes to remove + -- eg: {"rc1","rc2"} + -- Arrow Modes: + -- true: with arrow direction + -- false: against arrow direction + -- nil: ignores arrow direction + + if not atc_id then return false end + if (arrow_mode == nil) or (atc_arrow == arrow_mode) then + local rc = F.get_rc_safe() + rc_list = rc_list or {} + local rc_remove = {} + for _,v in pairs(rc_list) do + rc_remove[v] = true + end + -- remove codes from train's rc + local reinsert = {} + for token in rc:gmatch("[^%s]+") do + if not rc_remove[token] then + table.insert(reinsert,token) + end + end + -- insert new string to train's rc + set_rc(table.concat(reinsert," ")) + end + return reinsert +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) + return true +end \ No newline at end of file diff --git a/Tyard/nodes/(-4011,12,-2642).lua b/Tyard/nodes/(-4011,12,-2642).lua index 81a963d..d263812 100644 --- a/Tyard/nodes/(-4011,12,-2642).lua +++ b/Tyard/nodes/(-4011,12,-2642).lua @@ -1 +1,33 @@ -if S.yard_active and atc_arrow then set_autocouple() end \ No newline at end of file +-- Yard arrival checker +local function enter_yard() + F.dir(false) + F.yard_active(true) + atc_set_ars_disable(false) + atc_send("S6") + return +end + +__approach_callback_mode = 1 +if event.approach and not event.has_entered then + atc_set_ars_disable(true) + atc_set_lzb_trs(1) + return +end + +if event.train then + if F.yard_active() then + schedule_in(";10","recheck") + return + else + enter_yard() + end +end + +if event.schedule then + if F.yard_active() then + schedule_in(";10","recheck") + return + else + enter_yard() + end +end \ No newline at end of file diff --git a/Tyard/nodes/(-4011,12,-2647).lua b/Tyard/nodes/(-4011,12,-2647).lua new file mode 100644 index 0000000..3c9efc3 --- /dev/null +++ b/Tyard/nodes/(-4011,12,-2647).lua @@ -0,0 +1 @@ +--arrow points into yard -- config'd for Southbound entrance (North end of yard) local dir = "N" local entrance_signal = "Tyard_Enter_"..dir -- train enters from mainline. stop at signal to be safe if event.train and atc_arrow then atc_send("B0") end if atc_arrow then local rc = get_rc() or "" -- allow for manual working if rc:match("TYARD_NOSHUNT") then return end if S.yard_active then -- send train to "waiting" if can_set_route(entrance_signal,"WAITING") then set_route(entrance_signal,"WAITING") atc_set_text_outside("Waiting for yard to clear") atc_send("S6") else interrupt(5,"recheck") end else -- send train to "pickup" S.yard_active = true step_fc() local rc = get_rc() or "" S.rc = rc --check for RTS if S.single_dir == true or S.rc:match("TY_RTS") then S.dir = dir --working end = entrance dir S.RTS = true set_rc("AROUND_"..S.dir) else --invert S.dir --working end ~= entrance end if dir == "N" then S.dir = "S" else S.dir = "N" end end set_route(entrance_signal,"PICKUP") atc_set_text_outside("Proceeding to Classification Yard") atc_send("S4") end else -- train exiting set_rc(S.rc) S.yard_active = nil S.rc = nil S.dir = nil unset_autocouple() atc_send("SM") end \ No newline at end of file diff --git a/Tyard/nodes/(-4012,12,-2646).lua b/Tyard/nodes/(-4012,12,-2646).lua new file mode 100644 index 0000000..5199847 --- /dev/null +++ b/Tyard/nodes/(-4012,12,-2646).lua @@ -0,0 +1 @@ +-- Headshunt / Exit controller \ No newline at end of file diff --git a/Tyard/nodes/(-4027,12,-2655).lua b/Tyard/nodes/(-4027,12,-2655).lua index 39f9b81..136f70b 100644 --- a/Tyard/nodes/(-4027,12,-2655).lua +++ b/Tyard/nodes/(-4027,12,-2655).lua @@ -1 +1,35 @@ ---North pickup splitter local dir = "N" local lane = 0 --nothing below this line should indicate a hard direction --should be able to convert to function using only above args -------------------------------------------------- if S.yard_active then if atc_arrow then if S.dir == dir then set_route("TY"..dir.."_"..lane, "HEADSHUNT") local plen = train_length() local rc = split_at_fc("B0") local trc = "TY"..dir.."_"..rc if plen == train_length() and (rc == "" or S.rc:match(trc)) then S.exiting = true end if rc and rc ~= "" then set_rc("TY"..dir.."_"..rc) else set_rc(S.rc) S.exiting = true end else -- if S.dir ~= dir if S.RTS then -- loop around to other HS S.RTS = nil set_route("TY"..dir.."_"..lane,"AROUND") split_off_locomotive("B0") set_rc("AROUND_"..S.dir) return else atc_send("B0WRS4") end end end -- nothing to do if train goes against arrow end \ No newline at end of file +-- Classification track +local this_dir = true -- true = F.dir arrow points north +if F.yard_active() then + if atc_arrow then -- train is at working end + if F.has_rc("TY_arrive") then --first pass + 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 + 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 --> 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 + end + else --bounce train back towards working end + atc_send("S0WRD1S3") + 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 \ No newline at end of file diff --git a/Tyard/nodes/(-4027,12,-2731).lua b/Tyard/nodes/(-4027,12,-2731).lua index b04ffad..2b91223 100644 --- a/Tyard/nodes/(-4027,12,-2731).lua +++ b/Tyard/nodes/(-4027,12,-2731).lua @@ -1 +1,35 @@ ---South pickup splitter local dir = "S" local lane = 0 --nothing below this line should indicate a hard direction --should be able to convert to function using only above args -------------------------------------------------- if S.yard_active then if atc_arrow then if S.dir == dir then set_route("TY"..dir.."_"..lane, "HEADSHUNT") local plen = train_length() local rc = split_at_fc("B0") local trc = "TY"..dir.."_"..rc if plen == train_length() and (rc == "" or S.rc:match(trc)) then S.exiting = true end if rc and rc ~= "" then set_rc("TY"..dir.."_"..rc) else set_rc(S.rc) S.exiting = true end else -- if S.dir ~= dir if S.RTS then -- loop around to other HS S.RTS = nil set_route("TY"..dir.."_"..lane,"AROUND") split_off_locomotive("B0") set_rc("AROUND_"..S.dir) return else atc_send("B0WRS4") end end end -- nothing to do if train goes against arrow end \ No newline at end of file +-- Classification track +local this_dir = false -- true = F.dir arrow points north +if F.yard_active() then + if atc_arrow then -- train is at working end + if F.has_rc("TY_arrive") then --first pass + 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 + 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 --> 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 + end + else --bounce train back towards working end + atc_send("S0WRD1S3") + 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 \ No newline at end of file diff --git a/Tyard/nodes/(-4028,12,-2655).lua b/Tyard/nodes/(-4028,12,-2655).lua new file mode 100644 index 0000000..39f9b81 --- /dev/null +++ b/Tyard/nodes/(-4028,12,-2655).lua @@ -0,0 +1 @@ +--North pickup splitter local dir = "N" local lane = 0 --nothing below this line should indicate a hard direction --should be able to convert to function using only above args -------------------------------------------------- if S.yard_active then if atc_arrow then if S.dir == dir then set_route("TY"..dir.."_"..lane, "HEADSHUNT") local plen = train_length() local rc = split_at_fc("B0") local trc = "TY"..dir.."_"..rc if plen == train_length() and (rc == "" or S.rc:match(trc)) then S.exiting = true end if rc and rc ~= "" then set_rc("TY"..dir.."_"..rc) else set_rc(S.rc) S.exiting = true end else -- if S.dir ~= dir if S.RTS then -- loop around to other HS S.RTS = nil set_route("TY"..dir.."_"..lane,"AROUND") split_off_locomotive("B0") set_rc("AROUND_"..S.dir) return else atc_send("B0WRS4") end end end -- nothing to do if train goes against arrow end \ No newline at end of file diff --git a/Tyard/nodes/(-4028,12,-2731).lua b/Tyard/nodes/(-4028,12,-2731).lua new file mode 100644 index 0000000..b04ffad --- /dev/null +++ b/Tyard/nodes/(-4028,12,-2731).lua @@ -0,0 +1 @@ +--South pickup splitter local dir = "S" local lane = 0 --nothing below this line should indicate a hard direction --should be able to convert to function using only above args -------------------------------------------------- if S.yard_active then if atc_arrow then if S.dir == dir then set_route("TY"..dir.."_"..lane, "HEADSHUNT") local plen = train_length() local rc = split_at_fc("B0") local trc = "TY"..dir.."_"..rc if plen == train_length() and (rc == "" or S.rc:match(trc)) then S.exiting = true end if rc and rc ~= "" then set_rc("TY"..dir.."_"..rc) else set_rc(S.rc) S.exiting = true end else -- if S.dir ~= dir if S.RTS then -- loop around to other HS S.RTS = nil set_route("TY"..dir.."_"..lane,"AROUND") split_off_locomotive("B0") set_rc("AROUND_"..S.dir) return else atc_send("B0WRS4") end end end -- nothing to do if train goes against arrow end \ No newline at end of file diff --git a/Tyard/nodes/(-4031,12,-2655).lua b/Tyard/nodes/(-4031,12,-2655).lua index b6c6d60..7489acc 100644 --- a/Tyard/nodes/(-4031,12,-2655).lua +++ b/Tyard/nodes/(-4031,12,-2655).lua @@ -1 +1 @@ -F.EOL("N",1) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4031,12,-2731).lua b/Tyard/nodes/(-4031,12,-2731).lua index c4c1959..7489acc 100644 --- a/Tyard/nodes/(-4031,12,-2731).lua +++ b/Tyard/nodes/(-4031,12,-2731).lua @@ -1 +1 @@ -F.EOL("S",1) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4032,12,-2655).lua b/Tyard/nodes/(-4032,12,-2655).lua new file mode 100644 index 0000000..b6c6d60 --- /dev/null +++ b/Tyard/nodes/(-4032,12,-2655).lua @@ -0,0 +1 @@ +F.EOL("N",1) \ No newline at end of file diff --git a/Tyard/nodes/(-4032,12,-2731).lua b/Tyard/nodes/(-4032,12,-2731).lua new file mode 100644 index 0000000..c4c1959 --- /dev/null +++ b/Tyard/nodes/(-4032,12,-2731).lua @@ -0,0 +1 @@ +F.EOL("S",1) \ No newline at end of file diff --git a/Tyard/nodes/(-4035,12,-2655).lua b/Tyard/nodes/(-4035,12,-2655).lua index 3fd7dcb..7489acc 100644 --- a/Tyard/nodes/(-4035,12,-2655).lua +++ b/Tyard/nodes/(-4035,12,-2655).lua @@ -1 +1 @@ -F.EOL("N",2) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4035,12,-2731).lua b/Tyard/nodes/(-4035,12,-2731).lua index f15a717..7489acc 100644 --- a/Tyard/nodes/(-4035,12,-2731).lua +++ b/Tyard/nodes/(-4035,12,-2731).lua @@ -1 +1 @@ -F.EOL("S",2) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4036,12,-2655).lua b/Tyard/nodes/(-4036,12,-2655).lua new file mode 100644 index 0000000..3fd7dcb --- /dev/null +++ b/Tyard/nodes/(-4036,12,-2655).lua @@ -0,0 +1 @@ +F.EOL("N",2) \ No newline at end of file diff --git a/Tyard/nodes/(-4036,12,-2731).lua b/Tyard/nodes/(-4036,12,-2731).lua new file mode 100644 index 0000000..f15a717 --- /dev/null +++ b/Tyard/nodes/(-4036,12,-2731).lua @@ -0,0 +1 @@ +F.EOL("S",2) \ No newline at end of file diff --git a/Tyard/nodes/(-4039,12,-2655).lua b/Tyard/nodes/(-4039,12,-2655).lua index 592871f..7489acc 100644 --- a/Tyard/nodes/(-4039,12,-2655).lua +++ b/Tyard/nodes/(-4039,12,-2655).lua @@ -1 +1 @@ -F.EOL("N",3) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4039,12,-2731).lua b/Tyard/nodes/(-4039,12,-2731).lua index af4c22e..7489acc 100644 --- a/Tyard/nodes/(-4039,12,-2731).lua +++ b/Tyard/nodes/(-4039,12,-2731).lua @@ -1 +1 @@ -F.EOL("S",3) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4040,12,-2655).lua b/Tyard/nodes/(-4040,12,-2655).lua new file mode 100644 index 0000000..592871f --- /dev/null +++ b/Tyard/nodes/(-4040,12,-2655).lua @@ -0,0 +1 @@ +F.EOL("N",3) \ No newline at end of file diff --git a/Tyard/nodes/(-4040,12,-2731).lua b/Tyard/nodes/(-4040,12,-2731).lua new file mode 100644 index 0000000..af4c22e --- /dev/null +++ b/Tyard/nodes/(-4040,12,-2731).lua @@ -0,0 +1 @@ +F.EOL("S",3) \ No newline at end of file diff --git a/Tyard/nodes/(-4043,12,-2655).lua b/Tyard/nodes/(-4043,12,-2655).lua index c86923a..7489acc 100644 --- a/Tyard/nodes/(-4043,12,-2655).lua +++ b/Tyard/nodes/(-4043,12,-2655).lua @@ -1 +1 @@ -F.EOL("N",4) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4043,12,-2731).lua b/Tyard/nodes/(-4043,12,-2731).lua index 9227db4..7489acc 100644 --- a/Tyard/nodes/(-4043,12,-2731).lua +++ b/Tyard/nodes/(-4043,12,-2731).lua @@ -1 +1 @@ -F.EOL("S",4) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4044,12,-2655).lua b/Tyard/nodes/(-4044,12,-2655).lua new file mode 100644 index 0000000..c86923a --- /dev/null +++ b/Tyard/nodes/(-4044,12,-2655).lua @@ -0,0 +1 @@ +F.EOL("N",4) \ No newline at end of file diff --git a/Tyard/nodes/(-4044,12,-2731).lua b/Tyard/nodes/(-4044,12,-2731).lua new file mode 100644 index 0000000..9227db4 --- /dev/null +++ b/Tyard/nodes/(-4044,12,-2731).lua @@ -0,0 +1 @@ +F.EOL("S",4) \ No newline at end of file diff --git a/Tyard/nodes/(-4047,12,-2655).lua b/Tyard/nodes/(-4047,12,-2655).lua index 3ce2888..7489acc 100644 --- a/Tyard/nodes/(-4047,12,-2655).lua +++ b/Tyard/nodes/(-4047,12,-2655).lua @@ -1 +1 @@ -F.EOL("N",5) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4047,12,-2731).lua b/Tyard/nodes/(-4047,12,-2731).lua index e953f0e..7489acc 100644 --- a/Tyard/nodes/(-4047,12,-2731).lua +++ b/Tyard/nodes/(-4047,12,-2731).lua @@ -1 +1 @@ -F.EOL("S",5) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4048,12,-2655).lua b/Tyard/nodes/(-4048,12,-2655).lua new file mode 100644 index 0000000..3ce2888 --- /dev/null +++ b/Tyard/nodes/(-4048,12,-2655).lua @@ -0,0 +1 @@ +F.EOL("N",5) \ No newline at end of file diff --git a/Tyard/nodes/(-4048,12,-2731).lua b/Tyard/nodes/(-4048,12,-2731).lua new file mode 100644 index 0000000..e953f0e --- /dev/null +++ b/Tyard/nodes/(-4048,12,-2731).lua @@ -0,0 +1 @@ +F.EOL("S",5) \ No newline at end of file diff --git a/Tyard/nodes/(-4051,12,-2655).lua b/Tyard/nodes/(-4051,12,-2655).lua index 9e4298b..7489acc 100644 --- a/Tyard/nodes/(-4051,12,-2655).lua +++ b/Tyard/nodes/(-4051,12,-2655).lua @@ -1 +1 @@ -F.EOL("N",6) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4051,12,-2731).lua b/Tyard/nodes/(-4051,12,-2731).lua index 2fc4fc5..7489acc 100644 --- a/Tyard/nodes/(-4051,12,-2731).lua +++ b/Tyard/nodes/(-4051,12,-2731).lua @@ -1 +1 @@ -F.EOL("S",6) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4052,12,-2655).lua b/Tyard/nodes/(-4052,12,-2655).lua new file mode 100644 index 0000000..9e4298b --- /dev/null +++ b/Tyard/nodes/(-4052,12,-2655).lua @@ -0,0 +1 @@ +F.EOL("N",6) \ No newline at end of file diff --git a/Tyard/nodes/(-4052,12,-2731).lua b/Tyard/nodes/(-4052,12,-2731).lua new file mode 100644 index 0000000..2fc4fc5 --- /dev/null +++ b/Tyard/nodes/(-4052,12,-2731).lua @@ -0,0 +1 @@ +F.EOL("S",6) \ No newline at end of file diff --git a/Tyard/nodes/(-4055,12,-2655).lua b/Tyard/nodes/(-4055,12,-2655).lua index 4113ece..7489acc 100644 --- a/Tyard/nodes/(-4055,12,-2655).lua +++ b/Tyard/nodes/(-4055,12,-2655).lua @@ -1 +1 @@ -F.EOL("N",7) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4055,12,-2731).lua b/Tyard/nodes/(-4055,12,-2731).lua index edb2ef8..7489acc 100644 --- a/Tyard/nodes/(-4055,12,-2731).lua +++ b/Tyard/nodes/(-4055,12,-2731).lua @@ -1 +1 @@ -F.EOL("S",7) \ No newline at end of file +-- \ No newline at end of file diff --git a/Tyard/nodes/(-4056,12,-2655).lua b/Tyard/nodes/(-4056,12,-2655).lua new file mode 100644 index 0000000..4113ece --- /dev/null +++ b/Tyard/nodes/(-4056,12,-2655).lua @@ -0,0 +1 @@ +F.EOL("N",7) \ No newline at end of file diff --git a/Tyard/nodes/(-4056,12,-2731).lua b/Tyard/nodes/(-4056,12,-2731).lua new file mode 100644 index 0000000..edb2ef8 --- /dev/null +++ b/Tyard/nodes/(-4056,12,-2731).lua @@ -0,0 +1 @@ +F.EOL("S",7) \ No newline at end of file diff --git a/Tyard/nodes/(-4100,12,-2745).lua b/Tyard/nodes/(-4100,12,-2745).lua new file mode 100644 index 0000000..16007e9 --- /dev/null +++ b/Tyard/nodes/(-4100,12,-2745).lua @@ -0,0 +1,33 @@ +-- Yard arrival checker +local function enter_yard() + F.dir(true) + F.yard_active(true) + atc_set_ars_disable(false) + atc_send("S6") + return +end + +__approach_callback_mode = 1 +if event.approach and not event.has_entered then + atc_set_ars_disable(true) + atc_set_lzb_trs(1) + return +end + +if event.train then + if F.yard_active() then + schedule_in(";10","recheck") + return + else + enter_yard() + end +end + +if event.schedule then + if F.yard_active() then + schedule_in(";10","recheck") + return + else + enter_yard() + end +end \ No newline at end of file diff --git a/durt/nodes/(-3524,8,-2281).lua b/durt/nodes/(-3524,8,-2281).lua index 7d40fda..9afccd1 100644 --- a/durt/nodes/(-3524,8,-2281).lua +++ b/durt/nodes/(-3524,8,-2281).lua @@ -1,7 +1,6 @@ local dir = "east" if event.train and atc_arrow then - local rc = get_rc() or "" - if rc:match("Treefarm_headshunt_"..dir) then + if F.get_rc_safe():match("Treefarm_headshunt_"..dir) then schedule_in(";01",atc_id) return end diff --git a/durt/nodes/(-3541,8,-2276).lua b/durt/nodes/(-3541,8,-2276).lua new file mode 100644 index 0000000..22e5c4d --- /dev/null +++ b/durt/nodes/(-3541,8,-2276).lua @@ -0,0 +1,43 @@ +local dir = "east" +local split_indicators = {east=POS(-3559,9,-2282),west=POS(-3592,9,-2282)} +local loco_indicators = {east=POS(-3540,8,-2278),west=POS(-3593,8,-2277)} + +local inv_dir = (dir=="east" and "west" or "east") + +__approach_callback_mode = 1 +if event.approach and not event.has_entered then + atc_set_lzb_tsr(1) +end + +if event.train then +print(tostring(atc_arrow)) + local train_dir = F.get_rc_safe():match("Treefarm_headshunt_(%a%a%a%a)") + if not train_dir then return end -- ignore this train completely + if not atc_arrow then return end--nothing to do with this train yet + +print(train_dir.." "..dir) + if train_dir == dir then --train is matching arrow and has already bounced, split and let it pass + if getstate(split_indicators[dir]) == "red" then --there's an error somewhere, shouldn't get to this + print("error1") + return + end + if not F.get_rc_safe():match("Treefarm_collect") then + split_off_locomotive("A0B0",1) + atc_send("A1S3") + end + F.remove_rc({"Treefarm_loading"}) + set_rc(F.get_rc_safe().." Treefarm_rejoin_"..dir) + elseif train_dir == inv_dir then -- bounce the train +print("bounce") + if getstate(split_indicators[inv_dir]) == "red" then --there's an error somewhere, shouldn't get to this + print("error2") + return + end + set_rc(F.get_rc_safe().." Treefarm_collect") +print(F.get_rc_safe()) + atc_reset() + atc_send("S2D2S0WRS3") +print("do the bounce") + return + end +end \ No newline at end of file diff --git a/durt/nodes/(-3543,8,-2281).lua b/durt/nodes/(-3543,8,-2281).lua index a2adaf7..7489acc 100644 --- a/durt/nodes/(-3543,8,-2281).lua +++ b/durt/nodes/(-3543,8,-2281).lua @@ -1,56 +1 @@ -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 \ No newline at end of file +-- \ No newline at end of file diff --git a/durt/nodes/(-3543,8,-2282).lua b/durt/nodes/(-3543,8,-2282).lua new file mode 100644 index 0000000..a2adaf7 --- /dev/null +++ b/durt/nodes/(-3543,8,-2282).lua @@ -0,0 +1,56 @@ +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 \ No newline at end of file diff --git a/durt/nodes/(-3590,8,-2277).lua b/durt/nodes/(-3590,8,-2277).lua index 358f6c2..7489acc 100644 --- a/durt/nodes/(-3590,8,-2277).lua +++ b/durt/nodes/(-3590,8,-2277).lua @@ -1,43 +1 @@ -local dir = "west" -local split_indicators = {east=POS(-3559,9,-2282),west=POS(-3592,9,-2282)} -local loco_indicators = {east=POS(-3540,8,-2278),west=POS(-3593,8,-2277)} - -local inv_dir = (dir=="east" and "west" or "east") - -__approach_callback_mode = 1 -if event.approach and not event.has_entered then - atc_set_lzb_tsr(1) -end - -if event.train then -print(tostring(atc_arrow)) - local train_dir = F.get_rc_safe():match("Treefarm_headshunt_(%a%a%a%a)") - if not train_dir then return end -- ignore this train completely - if not atc_arrow then return end--nothing to do with this train yet - -print(train_dir.." "..dir) - if train_dir == dir then --train is matching arrow and has already bounced, split and let it pass - if getstate(split_indicators[dir]) == "red" then --there's an error somewhere, shouldn't get to this - print("error1") - return - end - if not F.get_rc_safe():match("Treefarm_collect") then - split_off_locomotive("A0B0",1) - atc_send("A1S3") - end - F.remove_rc({"Treefarm_loading"}) - set_rc(F.get_rc_safe().." Treefarm_rejoin_"..dir) - elseif train_dir == inv_dir then -- bounce the train -print("bounce") - if getstate(split_indicators[inv_dir]) == "red" then --there's an error somewhere, shouldn't get to this - print("error2") - return - end - set_rc(F.get_rc_safe().." Treefarm_collect") -print(F.get_rc_safe()) - atc_reset() - atc_send("S2D2S0WRS3") -print("do the bounce") - return - end -end \ No newline at end of file +-- \ No newline at end of file diff --git a/durt/nodes/(-3591,8,-2276).lua b/durt/nodes/(-3591,8,-2276).lua new file mode 100644 index 0000000..358f6c2 --- /dev/null +++ b/durt/nodes/(-3591,8,-2276).lua @@ -0,0 +1,43 @@ +local dir = "west" +local split_indicators = {east=POS(-3559,9,-2282),west=POS(-3592,9,-2282)} +local loco_indicators = {east=POS(-3540,8,-2278),west=POS(-3593,8,-2277)} + +local inv_dir = (dir=="east" and "west" or "east") + +__approach_callback_mode = 1 +if event.approach and not event.has_entered then + atc_set_lzb_tsr(1) +end + +if event.train then +print(tostring(atc_arrow)) + local train_dir = F.get_rc_safe():match("Treefarm_headshunt_(%a%a%a%a)") + if not train_dir then return end -- ignore this train completely + if not atc_arrow then return end--nothing to do with this train yet + +print(train_dir.." "..dir) + if train_dir == dir then --train is matching arrow and has already bounced, split and let it pass + if getstate(split_indicators[dir]) == "red" then --there's an error somewhere, shouldn't get to this + print("error1") + return + end + if not F.get_rc_safe():match("Treefarm_collect") then + split_off_locomotive("A0B0",1) + atc_send("A1S3") + end + F.remove_rc({"Treefarm_loading"}) + set_rc(F.get_rc_safe().." Treefarm_rejoin_"..dir) + elseif train_dir == inv_dir then -- bounce the train +print("bounce") + if getstate(split_indicators[inv_dir]) == "red" then --there's an error somewhere, shouldn't get to this + print("error2") + return + end + set_rc(F.get_rc_safe().." Treefarm_collect") +print(F.get_rc_safe()) + atc_reset() + atc_send("S2D2S0WRS3") +print("do the bounce") + return + end +end \ No newline at end of file diff --git a/durt/nodes/(-3591,8,-2281).lua b/durt/nodes/(-3591,8,-2281).lua index 48a6b55..7489acc 100644 --- a/durt/nodes/(-3591,8,-2281).lua +++ b/durt/nodes/(-3591,8,-2281).lua @@ -1,56 +1 @@ -local dir = "west" -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 \ No newline at end of file +-- \ No newline at end of file diff --git a/durt/nodes/(-3591,8,-2282).lua b/durt/nodes/(-3591,8,-2282).lua new file mode 100644 index 0000000..48a6b55 --- /dev/null +++ b/durt/nodes/(-3591,8,-2282).lua @@ -0,0 +1,56 @@ +local dir = "west" +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 \ No newline at end of file -- cgit v1.2.3