summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorautocommitter <autocommitter@linux-forks.de>2024-04-22 14:55:35 +0200
committerautocommitter <autocommitter@linux-forks.de>2024-04-22 14:55:35 +0200
commit9ef9e006c52db4a72872d417b99c1bea1e61ce35 (patch)
treed15672c69831045b6dd1e6d01a9437c861441146
parenta8fceffcbc8df02719981bc8ba101aca350295cb (diff)
downloadluaatc_envs-9ef9e006c52db4a72872d417b99c1bea1e61ce35.tar.gz
luaatc_envs-9ef9e006c52db4a72872d417b99c1bea1e61ce35.tar.bz2
luaatc_envs-9ef9e006c52db4a72872d417b99c1bea1e61ce35.zip
State at 2021-12-29
-rw-r--r--Crossroads/init_code.lua2
-rw-r--r--durt/init_code.lua6
-rw-r--r--durt/nodes/(-3524,8,-2281).lua18
-rw-r--r--durt/nodes/(-3541,8,-2277).lua43
-rw-r--r--durt/nodes/(-3543,8,-2281).lua56
-rw-r--r--durt/nodes/(-3552,16,-2275).lua3
-rw-r--r--durt/nodes/(-3588,8,-2275).lua3
-rw-r--r--durt/nodes/(-3589,8,-2283).lua1
-rw-r--r--durt/nodes/(-3590,8,-2277).lua43
-rw-r--r--durt/nodes/(-3591,8,-2281).lua56
-rw-r--r--durt/nodes/(-3604,8,-2281).lua18
-rw-r--r--durt/nodes/(-3618,8,-2278).lua1
-rw-r--r--durt/nodes/(-4117,16,-5793).lua1
13 files changed, 248 insertions, 3 deletions
diff --git a/Crossroads/init_code.lua b/Crossroads/init_code.lua
index e3b8a06..49dfcd6 100644
--- a/Crossroads/init_code.lua
+++ b/Crossroads/init_code.lua
@@ -203,7 +203,7 @@ function F.stn2gen(stn, trk, door, ret, chout, depspeed)
end
function F.tram2gen(stn,trk,ret)
- return F.stn2gen(stn,trk,"C",ret,true,4)
+ return F.stn2gen(stn,trk,"C",ret,true,8)
end
function F.disp2gen(stn)
diff --git a/durt/init_code.lua b/durt/init_code.lua
index 85776a4..1cc815b 100644
--- a/durt/init_code.lua
+++ b/durt/init_code.lua
@@ -23,6 +23,10 @@ if event.init then
S.yards = S.yards or list_of_yards
end
+F.get_rc_safe = function()
+ return get_rc() or ""
+end
+
F.remove_rc = function(rc_list,arrow_mode)
-- rc_list MUST be a table of rc codes to remove
-- eg: {"rc1","rc2"}
@@ -33,7 +37,7 @@ F.remove_rc = function(rc_list,arrow_mode)
if not event.train then return end
if (arrow_mode == nil) or (atc_arrow == arrow_mode) then
- local rc = get_rc() or ""
+ local rc = F.get_rc_safe()
rc_list = rc_list or {}
-- ensure rc-remove table can be read
diff --git a/durt/nodes/(-3524,8,-2281).lua b/durt/nodes/(-3524,8,-2281).lua
new file mode 100644
index 0000000..7d40fda
--- /dev/null
+++ b/durt/nodes/(-3524,8,-2281).lua
@@ -0,0 +1,18 @@
+local dir = "east"
+if event.train and atc_arrow then
+ local rc = get_rc() or ""
+ if rc:match("Treefarm_headshunt_"..dir) then
+ schedule_in(";01",atc_id)
+ return
+ 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,"S0WRS3CplA0S1D2S0WRA1S3")
+ return
+ end
+end \ No newline at end of file
diff --git a/durt/nodes/(-3541,8,-2277).lua b/durt/nodes/(-3541,8,-2277).lua
new file mode 100644
index 0000000..22e5c4d
--- /dev/null
+++ b/durt/nodes/(-3541,8,-2277).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
new file mode 100644
index 0000000..a2adaf7
--- /dev/null
+++ b/durt/nodes/(-3543,8,-2281).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/(-3552,16,-2275).lua b/durt/nodes/(-3552,16,-2275).lua
index 4225d33..6df6151 100644
--- a/durt/nodes/(-3552,16,-2275).lua
+++ b/durt/nodes/(-3552,16,-2275).lua
@@ -1 +1,2 @@
-digiline_send("","Active: "..tostring(S.TreeFarm.yard_active)) \ No newline at end of file
+digiline_send("","Active: "..tostring(S.TreeFarm.yard_active))
+print(getstate(POS(-3550,16,-2273))) \ No newline at end of file
diff --git a/durt/nodes/(-3588,8,-2275).lua b/durt/nodes/(-3588,8,-2275).lua
new file mode 100644
index 0000000..fb2ab3a
--- /dev/null
+++ b/durt/nodes/(-3588,8,-2275).lua
@@ -0,0 +1,3 @@
+do return end
+------------------------------------------------------------------ --West End of Loading Road local siding_id = "TreeFarm" local control_interface = POS(-3553,18,-2261) local hs_sig = POS(-3594,9,-2277) local hs_route = "Shunt Around Via Loop" if not S[siding_id] then S[siding_id] = {} end if not atc_arrow then atc_send("B1") end if not S[siding_id].yard_active then if atc_arrow then S[siding_id].yard_active = true S[siding_id].info = { ['rc'] = get_rc() or "", ['line'] = get_line() or "" } -- set_rc("AROUND")
+ step_fc() split_off_locomotive("B0WR") set_route(hs_sig,hs_route) atc_send("S4") end else if atc_arrow then -- train has rejoined atc_send("B0WD2RS1") -- reverse and load train set_rc(S[siding_id].info.rc) set_line(S[siding_id].info.line) unset_autocouple() interrupt_pos(control_interface,"Train Shunted||Now Loading") S[siding_id].info.rc = nil S[siding_id].info.line = nil S[siding_id].yard_active = nil end end \ No newline at end of file
diff --git a/durt/nodes/(-3589,8,-2283).lua b/durt/nodes/(-3589,8,-2283).lua
new file mode 100644
index 0000000..e53820f
--- /dev/null
+++ b/durt/nodes/(-3589,8,-2283).lua
@@ -0,0 +1 @@
+print("state" .. tostring(getstate(POS(-3592,9,-2282)))) \ No newline at end of file
diff --git a/durt/nodes/(-3590,8,-2277).lua b/durt/nodes/(-3590,8,-2277).lua
new file mode 100644
index 0000000..358f6c2
--- /dev/null
+++ b/durt/nodes/(-3590,8,-2277).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
new file mode 100644
index 0000000..48a6b55
--- /dev/null
+++ b/durt/nodes/(-3591,8,-2281).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
diff --git a/durt/nodes/(-3604,8,-2281).lua b/durt/nodes/(-3604,8,-2281).lua
new file mode 100644
index 0000000..59bd29d
--- /dev/null
+++ b/durt/nodes/(-3604,8,-2281).lua
@@ -0,0 +1,18 @@
+local dir = "west"
+if event.train and atc_arrow then
+ local rc = get_rc() or ""
+ if rc:match("Treefarm_headshunt_"..dir) then
+ schedule_in(";01",atc_id)
+ return
+ 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,"S0WRS3CplA0S1D2S0WRA1S3")
+ return
+ end
+end \ No newline at end of file
diff --git a/durt/nodes/(-3618,8,-2278).lua b/durt/nodes/(-3618,8,-2278).lua
new file mode 100644
index 0000000..893e8dd
--- /dev/null
+++ b/durt/nodes/(-3618,8,-2278).lua
@@ -0,0 +1 @@
+atc_send_to_train("335377","S0WRS5Cpl") \ No newline at end of file
diff --git a/durt/nodes/(-4117,16,-5793).lua b/durt/nodes/(-4117,16,-5793).lua
index 6e69dfb..8331ec8 100644
--- a/durt/nodes/(-4117,16,-5793).lua
+++ b/durt/nodes/(-4117,16,-5793).lua
@@ -1 +1,2 @@
+do return end
if event.train then print(atc_id) end \ No newline at end of file