diff options
author | autocommitter <autocommitter@linux-forks.de> | 2024-11-02 00:00:01 +0100 |
---|---|---|
committer | autocommitter <autocommitter@linux-forks.de> | 2024-11-02 00:00:01 +0100 |
commit | 91cc36ecd4e2c68040642dbaf0b0dc46106df61c (patch) | |
tree | 9c663a4233ddc831f6c3d0ed10a4d8166d4b93db /auto_yards/nodes | |
parent | 2d065ce9bedc6c7c0740a9148e96463749f8bf24 (diff) | |
download | luaatc_envs-91cc36ecd4e2c68040642dbaf0b0dc46106df61c.tar.gz luaatc_envs-91cc36ecd4e2c68040642dbaf0b0dc46106df61c.tar.bz2 luaatc_envs-91cc36ecd4e2c68040642dbaf0b0dc46106df61c.zip |
State at 2024-11-02
Diffstat (limited to 'auto_yards/nodes')
-rw-r--r-- | auto_yards/nodes/(-1946,16,840).lua | 2 | ||||
-rw-r--r-- | auto_yards/nodes/(-1947,16,837).lua | 2 | ||||
-rw-r--r-- | auto_yards/nodes/(-524,26,2481).lua | 1 | ||||
-rw-r--r-- | auto_yards/nodes/(-584,26,2481).lua | 17 | ||||
-rw-r--r-- | auto_yards/nodes/(-588,26,2504).lua | 49 | ||||
-rw-r--r-- | auto_yards/nodes/(-588,26,2534).lua | 1 | ||||
-rw-r--r-- | auto_yards/nodes/(-630,26,2454).lua | 88 | ||||
-rw-r--r-- | auto_yards/nodes/(-633,26,2456).lua | 4 | ||||
-rw-r--r-- | auto_yards/nodes/(-643,26,2475).lua | 74 | ||||
-rw-r--r-- | auto_yards/nodes/(-668,20,2478).lua | 4 | ||||
-rw-r--r-- | auto_yards/nodes/(-719,20,2475).lua | 2 | ||||
-rw-r--r-- | auto_yards/nodes/(417,17,4).lua | 2 |
12 files changed, 149 insertions, 97 deletions
diff --git a/auto_yards/nodes/(-1946,16,840).lua b/auto_yards/nodes/(-1946,16,840).lua index 4dd7c28..3176b25 100644 --- a/auto_yards/nodes/(-1946,16,840).lua +++ b/auto_yards/nodes/(-1946,16,840).lua @@ -13,6 +13,8 @@ local subs = { ['ARC_SB'] = {['pos'] = POS(-1973,16,800), ['msg'] = "notify"}, ['ARC_LOAD_DOCK'] = {['pos'] = POS(-1973,16,800), ['msg'] = "notify_local"}, ['CANNERY'] = {['pos'] = POS(-630,26,2454), ['msg'] = "notify"}, + ['S27_EXPORT'] = {['pos'] = POS(-1444,11,-2546), ['msg'] = "notify"}, + } if event.ext_int or event.punch then diff --git a/auto_yards/nodes/(-1947,16,837).lua b/auto_yards/nodes/(-1947,16,837).lua index 7ddaaf6..0a82dfd 100644 --- a/auto_yards/nodes/(-1947,16,837).lua +++ b/auto_yards/nodes/(-1947,16,837).lua @@ -1,2 +1,2 @@ -S.yards.ARC.notify = {['ARC_LOAD'] = true} +S.yards.ARC.notify = {['S27_EXPORT'] = true} print(S.yards.ARC.notify)
\ No newline at end of file diff --git a/auto_yards/nodes/(-524,26,2481).lua b/auto_yards/nodes/(-524,26,2481).lua index 74a7624..e119505 100644 --- a/auto_yards/nodes/(-524,26,2481).lua +++ b/auto_yards/nodes/(-524,26,2481).lua @@ -1,2 +1,3 @@ +if F.has_rc("CAN_INTRA_SHUFFLE") then atc_send("S0WD2RS2") return end -- EOL F.lane_EOL("CAN",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-584,26,2481).lua b/auto_yards/nodes/(-584,26,2481).lua index 46e3050..2995aaa 100644 --- a/auto_yards/nodes/(-584,26,2481).lua +++ b/auto_yards/nodes/(-584,26,2481).lua @@ -1,2 +1,19 @@ +-- Cannery departures lane modified + +local ind = POS(-594,26,2488) --notification indicator + +if F.has_rc("CAN_INTRA_SHUFFLE") then + if not atc_arrow then atc_send("A0S1CplD2S1") return end + split_off_locomotive("A0B0") + F.remove_rc("CAN_CLASS_DEPARTURES") + F.add_rc({ + "CAN_HS_W", + "CAN_send_to_locostore" + }) + atc_send("A1S3") + F.indicator(ind,true) --re-enable the notification as we haven't actually left the yard yet + F.indicator(S.yards.CAN.active_indicator_pos, false) -- disable the active indicator + return +end -- EOL F.lane_EOL("CAN",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-588,26,2504).lua b/auto_yards/nodes/(-588,26,2504).lua index cb800d9..5382804 100644 --- a/auto_yards/nodes/(-588,26,2504).lua +++ b/auto_yards/nodes/(-588,26,2504).lua @@ -1,26 +1,27 @@ -function tprint (tbl, indent) - local s = "" - if not indent then indent = 0 end - for k, v in pairs(tbl) do - local formatting = string.rep(" ", indent) .. "['"..k .. "']= " - if type(v) == "table" then - s = s .. formatting .. "{"..tprint(v, indent+1).."}" - else - s = s .. formatting .. tostring(v) - end - s = s .. ", " - end - return s -end +-- Cannery Dirt Loading Lane Modified +local sand_indicator = POS(-572,26,2515) --sand indicator -local str = "CAN_SB!S27!SAND_UNLOAD!DIRT_LOAD!S27_NB!CANNERY!DIRT_UNLOAD!SAND_LOAD" -local fc_table = {""} -for i=2,train_length() do -table.insert(fc_table,str) +if F.has_rc("CAN_INTRA_SHUFFLE") then + if not atc_arrow then return end + if F.has_rc("CAN_CLASS_DIRT_UNLOAD") then -- remove wagons, step the fc, return the wagons + F.remove_rc("CAN_CLASS_DIRT_UNLOAD") + F.add_rc({ + "CAN_HS_W", + "CAN_CLASS_SAND_LOAD" + }) + step_fc() + return + end + if F.has_rc("CAN_CLASS_SAND_LOAD") then -- remove wagons, step the fc, move wagons to departures + F.remove_rc("CAN_CLASS_SAND_LOAD") + F.add_rc({ + "CAN_HS_W", --departures track has Cpl function built in + "CAN_CLASS_DEPARTURES" + }) + step_fc() + F.indicator(sand_indicator, false) + return + end + return end -set_fc(fc_table, true) -print(tprint(get_fc())) - - --- EOL ---F.lane_EOL("CAN",true)
\ No newline at end of file +F.lane_EOL("CAN",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-588,26,2534).lua b/auto_yards/nodes/(-588,26,2534).lua index 74a7624..d783815 100644 --- a/auto_yards/nodes/(-588,26,2534).lua +++ b/auto_yards/nodes/(-588,26,2534).lua @@ -1,2 +1,3 @@ +if F.has_rc("CAN_INTRA_SHUFFLE") then atc_send("A0S0WRD5S3A1") return end -- EOL F.lane_EOL("CAN",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-630,26,2454).lua b/auto_yards/nodes/(-630,26,2454).lua index 5715c34..8dd1ff7 100644 --- a/auto_yards/nodes/(-630,26,2454).lua +++ b/auto_yards/nodes/(-630,26,2454).lua @@ -1,22 +1,53 @@ +-- Cannery Loco Storage local notification_id = "CAN" -local ind = POS(-594,26,2488) -local shuffle_ind = POS(-594,26,2487) +local ind = POS(-594,26,2488) --notification indicator +local sand_indicator = POS(-572,26,2515) --sand indicator local print_notification = true + +local sections = { + clay_factory = "327479", + departures = "484515" +} + local function send_train() - set_rc("FREIGHT CAN_LOCOSTORE CAN_LIGHT_EXIT EWL-W EWL S23 ARC_AUTO ARC_RTS ARC_COLLECT_CANNERY ARC_AUTO_S23N CANNERY CAN_RTS CAN_COLLECT_ARC") + if F.indicator(S.yards[notification_id].active_indicator_pos) then -- another train already in the yard. wait for it to exit first + print("yard still active") + schedule_in("0;2","send_train") + return + end + print("Sending Train") + local base_rc = { + "FREIGHT", + "CAN_LOCOSTORE", + "EWL-W", + "EWL", + "S23", + "ARC_AUTO", + "ARC_COLLECT_CANNERY", + "ARC_AUTO_S23N", + "CANNERY", + "CAN_COLLECT_DEPARTURES" + } + if section_occupancy(sections.clay_factory)[1] and F.indicator(sand_indicator) then + -- step the dirt wagons forward into sand wagons + print("Reshuffling sand export before departure") + base_rc[#base_rc+1] = "CAN_INTRA_SHUFFLE" + base_rc[#base_rc+1] = "CAN_HS_W" + base_rc[#base_rc+1] = "CAN_HS_W_AC" + base_rc[#base_rc+1] = "CAN_CLASS_DIRT_UNLOAD" + F.indicator(S.yards.CAN.active_indicator_pos, true) --activate the yard to prevent other trains entering while we're moving around + elseif section_occupancy(sections.departures)[1] then --collect departures wagons before departing proper + base_rc[#base_rc+1] = "CAN_REENTER_YARD" + print("Collecting Departures") + else + base_rc[#base_rc+1] = "CAN_LIGHT_EXIT" + end + print("rc list set") + set_rc(table.concat(base_rc," ")) + print("rc set") atc_send("S0WRD2A1S4") F.indicator(ind,false) -end - -local function shuffle_wagons() - F.indicator(S.yards[notification_id].active_indicator_pos, true) --stop other trains entering the yard - F.indicator(S.yards[notification_id].dir_indicator_pos,true) - F.indicator(shuffle_ind,false) - F.indicator(ind,true) - S.yards[notification_id].shuffle_stage = 1 -- set a shuffle stage counter - set_rc("CAN_LOCOSTORE CAN_SHUFFLE") - atc_send("S0WRD2A1S4") --send train to headshunt - return + print("train sent") end if event.ext_int then @@ -30,44 +61,27 @@ if event.ext_int then F.indicator(ind,true) return end - elseif event.message == "shuffle" then - if atc_id then - if not F.indicator(S.yards[notification_id].active_indicator_pos) then - shuffle_wagons() - return - end - schedule_in(":05","shuffle") - return - else - F.indicator(shuffle_ind,true) - return - end + return end return end if event.schedule then - if event.message=="shuffle" then - if not F.idicator(S.yards[notification_id].active_indicator_pos) then - shuffle_wagons() - return - end - schedule_in(":05","shuffle") + if event.msg=="send_train" then + send_train() return end return end if event.train then - unset_autocouple() - if F.indicator(shuffle_ind) then - shuffle_wagons() - return - end + print("Train arrived") if F.indicator(ind) then + print("indicator on. Sending Train") send_train() return end + print("train movements completed") atc_send("B0") return end
\ No newline at end of file diff --git a/auto_yards/nodes/(-633,26,2456).lua b/auto_yards/nodes/(-633,26,2456).lua deleted file mode 100644 index 8dc117b..0000000 --- a/auto_yards/nodes/(-633,26,2456).lua +++ /dev/null @@ -1,4 +0,0 @@ -if event.punch then - F.indicator(S.yards.CAN.active_indicator_pos,false) - interrupt_pos(POS(-630,26,2454),"shuffle") -end
\ No newline at end of file diff --git a/auto_yards/nodes/(-643,26,2475).lua b/auto_yards/nodes/(-643,26,2475).lua index 086074b..cd822d6 100644 --- a/auto_yards/nodes/(-643,26,2475).lua +++ b/auto_yards/nodes/(-643,26,2475).lua @@ -1,37 +1,50 @@ --- Automatic bouncer for headshunts, assuming longer headshunt than train length. Arrow points into headshunt -local rev_rc = "CAN_HS_N" -local rm_rc = true -local autocouple = "CAN_HS_N_AC" -local rm_cpl_rc = true - - -__approach_callback_mode = 1 - -if event.approach and not event.has_entered then - atc_set_lzb_tsr(3) - atc_set_ars_disable(true) - return -end +--Cannery Yard Headshunt +local yard_id = "CAN" if event.train then - if not atc_arrow then --train has bounced - if F.has_rc(autocouple) then - atc_send("CplS0WD2S1") - if rm_cpl_rc then F.remove_rc({autocouple}) end + if F.has_rc(yard_id.."_LIGHT_EXIT") then return end + if F.has_rc(yard_id.."_NOSHUNT") then return end + if F.has_rc("CAN_HS_W") then + if not atc_arrow then + atc_send("B3") + schedule_in("0;01", atc_id) + return end - return - end - - if not F.has_rc(rev_rc) then --not our train. disregard atc_set_ars_disable(false) + F.remove_rc("CAN_HS_W") + if F.has_rc("CAN_HS_W_AC") then + F.remove_rc("CAN_HS_W_AC") + atc_send("S3CplS0D2S3") + return + end return end - if rm_rc then F.remove_rc({rev_rc}) end - schedule_in(";01",atc_id) - return + if train_length() == 1 then -- eliminates near half the trains + if F.has_rc(yard_id.."_LOCOSTORE") then -- specifies only the relevant train + if F.has_rc(yard_id.."_DEPART") and F.has_rc(yard_id.."_FINAL_COLLECT") and F.has_rc(yard_id.."_HEADSHUNT") then --only activate if train is set to depart anyway + if not atc_arrow then -- train is pointing towards exit. let it pass and the reverse it + atc_set_ars_disable(true) + schedule_in(";01",atc_id) -- prepare to reverse the train + return + else --train has reversed. send it to the siding and deactivate the yard + F.remove_rc({yard_id.."_DEPART",yard_id.."_FINAL_COLLECT"}) + F.add_rc(yard_id.."_send_to_locostore") + atc_set_ars_disable(false) + F.indicator(S.yards[yard_id].active_indicator_pos, false) + S.yards[yard_id].departure_time = rwt.now() + S.yards[yard_id].departure_length = S.yards[yard_id].arrival_length + + if S.yards[yard_id].notify_pos then + interrupt_pos(S.yards[yard_id].notify_pos,"notify") + end + return + end + end + end + end end -if event.schedule then +if event.schedule then --this is a duplicate of the reversing schedule in the env anyway if not atc_id then --bounce the train that just passed atc_send_to_train(event.msg,"B0WRD1A1S3") else @@ -40,6 +53,13 @@ if event.schedule then 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.indicator(yard.error_indicator_pos,true) end end -end
\ No newline at end of file + return +end + + + +-- if all else fails, do a normal headshunt_yard function +F.headshunt_yard(yard_id,true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-668,20,2478).lua b/auto_yards/nodes/(-668,20,2478).lua index 7c582c0..beb2639 100644 --- a/auto_yards/nodes/(-668,20,2478).lua +++ b/auto_yards/nodes/(-668,20,2478).lua @@ -1,3 +1,3 @@ -- arrival -if not F.has_rc("CANNERY") then return end -F.yard_arrival("CAN",false)
\ No newline at end of file +if not F.has_rc("CANNERY") and not atc_arrow then return end +F.yard_arrival("CAN", false, true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-719,20,2475).lua b/auto_yards/nodes/(-719,20,2475).lua index acfc06a..350ff88 100644 --- a/auto_yards/nodes/(-719,20,2475).lua +++ b/auto_yards/nodes/(-719,20,2475).lua @@ -1,6 +1,6 @@ local yard_id = "CAN" if event.train then - if F.has_rc(yard_id.."_LIGHT_EXIT") then + if F.has_rc(yard_id.."_LIGHT_EXIT") or F.has_rc(yard_id.."_REENTER_YARD") then F.remove_rc(yard_id.."_LIGHT_EXIT") atc_set_ars_disable(false) atc_send("SM") diff --git a/auto_yards/nodes/(417,17,4).lua b/auto_yards/nodes/(417,17,4).lua index b634cde..b72d4eb 100644 --- a/auto_yards/nodes/(417,17,4).lua +++ b/auto_yards/nodes/(417,17,4).lua @@ -25,7 +25,7 @@ if event.channel=="clock" then txt[#txt+1] = "Active: " .. tostring(F.indicator(info.active_indicator_pos)) txt[#txt+1] = "Direction: " .. tostring(F.indicator(info.dir_indicator_pos)) - txt[#txt+1] = "Last Train: " .. tostring(info.last_id).." ("..tostring(info.arrival_length).."-"..tostring(info.departure_length)..")" + txt[#txt+1] = "Last Train: " .. tostring(S.known_trains[info.last_id] or info.last_id).." ("..tostring(info.arrival_length).."-"..tostring(info.departure_length)..")" txt2[#txt2+1] = "Time: "..tostring(rwt.to_string(info.arrival_time)).."+"..tostring(rwt.to_string(rwt.diff(info.arrival_time,info.departure_time))) digiline_send(yard_id.."_1",table.concat(txt,"\n")) |