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 | 387155be168afea0d3917b6d9936d301ca33b03a (patch) | |
tree | e3ec3e72809db59d332cd407ec9f680bc14d4a1e | |
parent | 21b3997259ef9559c56e114e1733049dd2ebe8ac (diff) | |
download | luaatc_envs-387155be168afea0d3917b6d9936d301ca33b03a.tar.gz luaatc_envs-387155be168afea0d3917b6d9936d301ca33b03a.tar.bz2 luaatc_envs-387155be168afea0d3917b6d9936d301ca33b03a.zip |
State at 2022-06-14
-rw-r--r-- | auto_yards/init_code.lua | 8 | ||||
-rw-r--r-- | subway/nodes/(-1251,17,-463).lua | 63 |
2 files changed, 68 insertions, 3 deletions
diff --git a/auto_yards/init_code.lua b/auto_yards/init_code.lua index 6286947..0664eb9 100644 --- a/auto_yards/init_code.lua +++ b/auto_yards/init_code.lua @@ -100,7 +100,7 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list = string eg: "rc1 rc2 rc3" -- prep rc_list to useable format local rc_remove = {} if type(rc_list) == "string" then - for word in pairs(rc_list:gmatch("[^%s]+")) do + for word in rc_list:gmatch("[^%s]+") do rc_remove[word] = true end elseif type(rc_list) == "table" then @@ -146,15 +146,19 @@ F.yard_arrival = function(yard_id,this_dir) -- arrow points towards yard local function enter_yard() if not atc_id then F.indicator(yard.error_indicator_pos,true) + return end F.indicator(yard.dir_indicator_pos,this_dir) F.indicator(yard.active_indicator_pos,true) F.add_rc({yard_id.."_ARRIVE"}) + local rts = false if F.has_rc(yard_id.."_RTS") then --save the RTS flag as it's removed during the arrival procedure F.add_rc({yard_id.."_HAS_RTS"}) + rts = true end 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") return end @@ -357,7 +361,7 @@ F.headshunt_exit = function(yard_id,this_dir) -- arrow points out of yard schedule_in(";05","deactivate_check") -- wait a little to ensure train is clear from headshunt to deactivate yard print(F.get_rc_safe()) return - end + end -- if not _DEPART then let the train pass as extra space for the bounce back to the yard else atc_send("BBOL") F.indicator(yard.error_indicator_pos,true) diff --git a/subway/nodes/(-1251,17,-463).lua b/subway/nodes/(-1251,17,-463).lua index 34c4a32..1999e5b 100644 --- a/subway/nodes/(-1251,17,-463).lua +++ b/subway/nodes/(-1251,17,-463).lua @@ -1 +1,62 @@ -F.stn("Mnv1W", "Grs1W", "Lih1E", "L")
\ No newline at end of file +--F.stn("Mnv1W", "Grs1W", "Lih1E", "L") +--print("Apple Plains: Train",atc_id,"event",event.type,"sigstate",getstate("Apl1W")) +local this = "Grs1W" +local prev1 = "Mnv1W" +local doors = "L" +local next = "Lih1E" + + if not atc_id then + print("Gram-Schmidt Street WTF - Bug happened again (same bug as in Apple Grove?). Trying laterrr...") + interrupt(20, "ready") + return + end + if not atc_arrow then + atc_send("B0") + error("Train passed in wrong direction!") + end + depart=false + if event.train then + setstate(prev1, "red") + if prev2 then setstate(prev2, "red") end + atc_send("B0O"..doors) + + if not nohalt then + interrupt(waittime or (ret_sw and 20 or 7), "ready") + atc_set_text_inside(F.stnname(this)) + end + end + if (event.int and event.message=="ready") or (event.train and nohalt) then + if getstate(this)=="green" and (not osig or getstate(osig)=="green") then + if ret_sw then + atc_send("OCD1B0WRS"..(dps or "M")) + setstate(ret_sw, ret_st) + else + atc_send("OCD1S"..(dps or "M")) + setstate(prev1, "green") + if line1 then --this call did not come from F.stn, do union stuff + setstate(prev2, "green") + if S.line[atc_id]==line1 then + if S.union_waiting[prev2] then setstate(prev1, "red") end + else + if S.union_waiting[prev1] then setstate(prev2, "red") end + end + end + end + setstate(this, "red") + atc_set_text_inside("Next stop: "..F.stnname(next)) + depart=true + nodepartc=nil + else + interrupt(F.rant(), "ready") + nodepartc=nodepartc and nodepartc+1 or 0 + if nodepartc>=10 then + atc_set_text_inside(F.stnname(this).."\nLine out of order!") + else + if (not osig or getstate(osig)=="green") then + atc_set_text_inside(F.stnname(this).."\nWaiting for preceding train...") + else + atc_set_text_inside(F.stnname(this).."\nWaiting for oncoming train...") + end + end + end + end
\ No newline at end of file |