diff options
author | autocommitter <autocommitter@linux-forks.de> | 2024-04-22 14:57:40 +0200 |
---|---|---|
committer | autocommitter <autocommitter@linux-forks.de> | 2024-04-22 14:57:40 +0200 |
commit | 8e22d662e526a44b9832490d1a9f4d0ff6115609 (patch) | |
tree | a93874b3620345ab68f851fb07f003e4ad41d13e | |
parent | 387155be168afea0d3917b6d9936d301ca33b03a (diff) | |
download | luaatc_envs-8e22d662e526a44b9832490d1a9f4d0ff6115609.tar.gz luaatc_envs-8e22d662e526a44b9832490d1a9f4d0ff6115609.tar.bz2 luaatc_envs-8e22d662e526a44b9832490d1a9f4d0ff6115609.zip |
State at 2022-06-15
-rw-r--r-- | auto_yards/init_code.lua | 50 | ||||
-rw-r--r-- | durt/nodes/(-1459,11,-2588).lua | 8 | ||||
-rw-r--r-- | durt/nodes/(-1514,11,-2588).lua | 19 | ||||
-rw-r--r-- | durt/nodes/(-1515,7,-2625).lua | 1 |
4 files changed, 47 insertions, 31 deletions
diff --git a/auto_yards/init_code.lua b/auto_yards/init_code.lua index 0664eb9..64c0773 100644 --- a/auto_yards/init_code.lua +++ b/auto_yards/init_code.lua @@ -13,19 +13,19 @@ if event.init then ]]-- TY = { active_indicator_pos = POS(-4025,14,-2659), - dir_indicator_pos = POS(-4025,13,-2665), + dir_indicator_pos = POS(-4025,12,-2665), error_indicator_pos = POS(-4025,13,-2671), headshunt_max = 5, }, BY = { active_indicator_pos = POS(-2002,3,-1099), - dir_indicator_pos = POS(-2009,3,-1099), + dir_indicator_pos = POS(-2009,3,-1101), error_indicator_pos = POS(-1999,3,-1099), headshunt_max = 5, }, IP = { active_indicator_pos = POS(1179,16,3848), - dir_indicator_pos = POS(1179,16,3855), + dir_indicator_pos = POS(1177,16,3855), error_indicator_pos = POS(1179,16,3850), headshunt_max = 5, }, @@ -56,7 +56,7 @@ F.has_rc = function(query,rc_list) -- query = string, single entry for word in rc_list:gmatch("[^%s]+") do if word == query then return true end end - print(F.get_rc_safe()) + -- print(F.get_rc_safe()) return false end @@ -83,7 +83,7 @@ F.add_rc = function(rc_list) -- rc_list = string or table, eg: {"rc1","rc2"} OR rc_list = table.concat(rc_list," ") end set_rc(F.get_rc_safe().." "..rc_list) - print(F.get_rc_safe()) + -- print(F.get_rc_safe()) return true end @@ -120,7 +120,7 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list = string eg: "rc1 rc2 rc3" -- insert new string to train's rc set_rc(table.concat(reinsert," ")) end - print(F.get_rc_safe()) + -- print(F.get_rc_safe()) return reinsert end @@ -132,7 +132,7 @@ F.remove_rc_match = function(rc_list) -- rc_list = pattern string, single entry, table.insert(rm,v) end F.remove_rc(rm) - print(F.get_rc_safe()) + -- print(F.get_rc_safe()) return rm end @@ -156,6 +156,7 @@ F.yard_arrival = function(yard_id,this_dir) -- arrow points towards yard F.add_rc({yard_id.."_HAS_RTS"}) rts = true end + step_fc() atc_set_ars_disable(false) atc_send("S6") print("Train "..atc_id.." enters yard ".. yard_id.." from the "..tostring(this_dir).." direction and "..((rts and "will") or "won't").." return in the same direction") @@ -171,6 +172,7 @@ F.yard_arrival = function(yard_id,this_dir) -- arrow points towards yard if event.train then if F.indicator(yard.active_indicator_pos) then + print("Train "..atc_id.." has arrived at "..yard_id.." yard and has to wait for the yard to deactivate.") schedule_in(";10","recheck") return else @@ -227,22 +229,20 @@ F.classification = function(yard_id, this_dir) -- arrow points towards headshunt return -- train has departed for headshunt/around end --else train has arrived from wagon count and headshunt/around F.remove_rc({yard_id.."_ARRIVE"}) - step_fc() end if this_dir == F.indicator(yard.dir_indicator_pos) then --train has bounced and is ready to classify wagon(s) - -- local pre_split = train_length() - local lane = split_at_fc("A0B0",yard.headshunt_max) -- where to classify this rake -- headshunt length local locos = tonumber(F.get_rc_safe():match(yard_id.."_LOCOS_(%d+)")) or 1 --saved loco count local wagons = tonumber(F.get_rc_safe():match(yard_id.."_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({yard_id.."_LAST_CLASS"}) - end + local lane = split_at_fc("A0B0",yard.headshunt_max) -- where to classify this rake -- headshunt length + local this_rake = train_length() - locos if lane ~= "" then F.add_rc({yard_id.."_CLASS_"..lane}) end + if this_rake == wagons then -- mark for last_classification + F.add_rc({yard_id.."_LAST_CLASS"}) + end F.remove_rc_match(yard_id.."_WAGONS_%d+") - F.add_rc({yard_id.."_HEADSHUNT",yard_id.."_WAGONS_"..wagons-this_rake}) + F.add_rc({yard_id.."_HEADSHUNT",yard_id.."_WAGONS_"..wagons-this_rake}) -- subtract these wagons from the overall wagon count atc_set_ars_disable(false) set_autocouple() else --bounce train back towards working end @@ -278,13 +278,11 @@ F.headshunt_yard = function(yard_id,this_dir) -- arrow points toward yard schedule_in(";01",atc_id) return else + print("Preparing train "..atc_id.." to depart "..yard_id.." yard.") if get_line() ~= "LHF" then -- LHF trains will always only collect the * lane for that direction. This code is for other trains - local collect,next_collect = F.get_rc_safe():match(yard_id.."_COLLECT_(%S+)") + local collect = F.get_rc_safe():match(yard_id.."_COLLECT_(%S+)") -- will only match to the first _COLLECT RC to avoid excessively long trains in the headshunt if collect then --train needs to collect a rake from the yard before departing - F.add_rc({yard_id.."_CLASS_"..collect}) - if not next_collect then - F.add_rc({yard_id.."_FINAL_COLLECT"}) - end + F.add_rc({yard_id.."_CLASS_"..collect,yard_id.."_FINAL_COLLECT"}) schedule_in(";01",atc_id) return end @@ -293,8 +291,6 @@ F.headshunt_yard = function(yard_id,this_dir) -- arrow points toward yard schedule_in(";01",atc_id) return end - - end --else let train proceed forward to the exit controller without a rake @@ -316,7 +312,7 @@ F.headshunt_yard = function(yard_id,this_dir) -- arrow points toward yard if event.schedule then if not atc_id then --bounce the train that just passed - atc_send_to_train(event.msg,"B0WRD1S3A1") + atc_send_to_train(event.msg,"B0WRD1A1S3") else if atc_id == event.msg then --train hasn't fully passed yet, wait a bit longer schedule_in(";01",atc_id) @@ -346,7 +342,8 @@ F.headshunt_exit = function(yard_id,this_dir) -- arrow points out of yard if event.train then if atc_arrow and (F.indicator(yard.dir_indicator_pos) == this_dir) then if F.has_rc(yard_id.."_DEPART") then - print("Train departs yard to mainline at full speed") + print("Train "..atc_id.." has a length of "..train_length()) + print("It will depart in the "..tostring(this_dir).." direction.") unset_autocouple() F.remove_rc({yard_id.."_FINAL_COLLECT",yard_id.."_DEPART"}) F.remove_rc_match(yard_id.."_LOCOS_%d+") @@ -356,10 +353,9 @@ F.headshunt_exit = function(yard_id,this_dir) -- arrow points out of yard F.add_rc({yard_id.."_RTS"}) end atc_set_ars_disable(false) - -- set_route(exit_signal,"Exit Yard") atc_send("S6D10SM") schedule_in(";05","deactivate_check") -- wait a little to ensure train is clear from headshunt to deactivate yard - print(F.get_rc_safe()) + -- print(F.get_rc_safe()) return end -- if not _DEPART then let the train pass as extra space for the bounce back to the yard else @@ -372,7 +368,7 @@ F.headshunt_exit = function(yard_id,this_dir) -- arrow points out of yard if event.msg == "deactivate_check" then if not atc_id then F.indicator(yard.active_indicator_pos,false) - print("Yard Disabled") + print(yard_id.." yard Disabled") else schedule_in(";05","deactivate_check") return diff --git a/durt/nodes/(-1459,11,-2588).lua b/durt/nodes/(-1459,11,-2588).lua new file mode 100644 index 0000000..3b1b94b --- /dev/null +++ b/durt/nodes/(-1459,11,-2588).lua @@ -0,0 +1,8 @@ +if event.train and atc_arrow then + atc_set_ars_disable(false) + if F.has_rc("S27_Overburden") and train_length() == 1 then + F.add_rc({"S27_HS_E","S27_DOCK3"}) + return + end + F.add_rc("S27_EXIT") +end
\ No newline at end of file diff --git a/durt/nodes/(-1514,11,-2588).lua b/durt/nodes/(-1514,11,-2588).lua index ad879df..be0bf95 100644 --- a/durt/nodes/(-1514,11,-2588).lua +++ b/durt/nodes/(-1514,11,-2588).lua @@ -1,6 +1,17 @@ -if event.train and atc_arrow then - atc_set_ars_disable(false) - atc_send("S3") - set_rc(get_rc().." S27_EXIT_BRIDGE") +__approach_callback_mode = 2 +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 atc_arrow then + atc_set_ars_disable(false) + atc_send("S3") + F.add_rc("S27_EXIT_BRIDGE") + return + end + atc_send("S1") + step_fc() end
\ No newline at end of file diff --git a/durt/nodes/(-1515,7,-2625).lua b/durt/nodes/(-1515,7,-2625).lua new file mode 100644 index 0000000..7489acc --- /dev/null +++ b/durt/nodes/(-1515,7,-2625).lua @@ -0,0 +1 @@ +--
\ No newline at end of file |