summaryrefslogtreecommitdiff
path: root/Crossroads
diff options
context:
space:
mode:
authorautocommitter <autocommitter@linux-forks.de>2024-04-22 15:02:54 +0200
committerautocommitter <autocommitter@linux-forks.de>2024-04-22 15:02:54 +0200
commitc9e1df06b462e513057ac3e0e7489c74b56e2af8 (patch)
tree629d1d58755d5eae678b2ca19249727682581fbc /Crossroads
parent983c42157ac3dff23df2d693d1d972179ab00232 (diff)
downloadluaatc_envs-c9e1df06b462e513057ac3e0e7489c74b56e2af8.tar.gz
luaatc_envs-c9e1df06b462e513057ac3e0e7489c74b56e2af8.tar.bz2
luaatc_envs-c9e1df06b462e513057ac3e0e7489c74b56e2af8.zip
State at 2023-11-07
Diffstat (limited to 'Crossroads')
-rw-r--r--Crossroads/init_code.lua46
-rw-r--r--Crossroads/nodes/(1538,6,7946).lua1
-rw-r--r--Crossroads/nodes/(1554,6,7941).lua1
-rw-r--r--Crossroads/nodes/(1610,6,7934).lua1
-rw-r--r--Crossroads/nodes/(1610,6,7943).lua1
-rw-r--r--Crossroads/nodes/(1611,6,7941).lua1
-rw-r--r--Crossroads/nodes/(1612,6,7941).lua1
-rw-r--r--Crossroads/nodes/(1612,6,7942).lua1
-rw-r--r--Crossroads/nodes/(1612,6,7949).lua1
-rw-r--r--Crossroads/nodes/(1617,6,7943).lua1
-rw-r--r--Crossroads/nodes/(1623,6,7925).lua1
-rw-r--r--Crossroads/nodes/(1630,6,7971).lua1
12 files changed, 57 insertions, 0 deletions
diff --git a/Crossroads/init_code.lua b/Crossroads/init_code.lua
index 67c2544..067c474 100644
--- a/Crossroads/init_code.lua
+++ b/Crossroads/init_code.lua
@@ -22,6 +22,52 @@ function F.error(errorcode)
error(F.errlist[errorcode])
end
+-- Level crossing handling
+if not S.crossings then S.crossings = {} end
+
+local crossing_light_count = {
+ NRG_1 = 2,
+ NRG_2 = 4,
+ NRG_3 = 3,
+ NRG_4 = 2,
+ NRG_5 = 4,
+}
+
+local function update_light(loc, k, v)
+ local t = S.crossings[loc]
+ if not t then
+ t = {}
+ S.crossings[loc] = t
+ end
+ t[k] = v
+ local val = "on"
+ if next(t) == nil then
+ val = "off"
+ end
+ local pfx = loc .. "_"
+ local count = crossing_light_count[loc]
+ if not count then return end
+ for i = 1, count do
+ setstate(pfx .. i, val)
+ end
+end
+
+function F.x_on(t)
+ if event.type ~= "train" then return end
+ if not atc_arrow then return end
+ for loc, k in pairs(t) do
+ update_light(loc, k, true)
+ end
+end
+
+function F.x_off(t)
+ if event.type ~= "train" then return end
+ if not atc_arrow then return end
+ for loc, k in pairs(t) do
+ update_light(loc, k, nil)
+ end
+end
+
--[[ F.stnbasic - Basis for all station functions:
(By default, nil is defined as false or "no changes")
stn = Station Code
diff --git a/Crossroads/nodes/(1538,6,7946).lua b/Crossroads/nodes/(1538,6,7946).lua
new file mode 100644
index 0000000..8d006a8
--- /dev/null
+++ b/Crossroads/nodes/(1538,6,7946).lua
@@ -0,0 +1 @@
+F.x_on {NRG_1 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1554,6,7941).lua b/Crossroads/nodes/(1554,6,7941).lua
new file mode 100644
index 0000000..286d43b
--- /dev/null
+++ b/Crossroads/nodes/(1554,6,7941).lua
@@ -0,0 +1 @@
+F.x_off {NRG_1 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1610,6,7934).lua b/Crossroads/nodes/(1610,6,7934).lua
new file mode 100644
index 0000000..bde0332
--- /dev/null
+++ b/Crossroads/nodes/(1610,6,7934).lua
@@ -0,0 +1 @@
+F.x_on{NRG_2 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1610,6,7943).lua b/Crossroads/nodes/(1610,6,7943).lua
new file mode 100644
index 0000000..11efa6f
--- /dev/null
+++ b/Crossroads/nodes/(1610,6,7943).lua
@@ -0,0 +1 @@
+F.x_on{NRG_4 = 1, NRG_5 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1611,6,7941).lua b/Crossroads/nodes/(1611,6,7941).lua
new file mode 100644
index 0000000..11efa6f
--- /dev/null
+++ b/Crossroads/nodes/(1611,6,7941).lua
@@ -0,0 +1 @@
+F.x_on{NRG_4 = 1, NRG_5 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1612,6,7941).lua b/Crossroads/nodes/(1612,6,7941).lua
new file mode 100644
index 0000000..9e8bcab
--- /dev/null
+++ b/Crossroads/nodes/(1612,6,7941).lua
@@ -0,0 +1 @@
+F.x_on{NRG_3 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1612,6,7942).lua b/Crossroads/nodes/(1612,6,7942).lua
new file mode 100644
index 0000000..56bd0a1
--- /dev/null
+++ b/Crossroads/nodes/(1612,6,7942).lua
@@ -0,0 +1 @@
+F.x_on {NRG_3 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1612,6,7949).lua b/Crossroads/nodes/(1612,6,7949).lua
new file mode 100644
index 0000000..3ed95ea
--- /dev/null
+++ b/Crossroads/nodes/(1612,6,7949).lua
@@ -0,0 +1 @@
+F.x_off{NRG_2 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1617,6,7943).lua b/Crossroads/nodes/(1617,6,7943).lua
new file mode 100644
index 0000000..3ed95ea
--- /dev/null
+++ b/Crossroads/nodes/(1617,6,7943).lua
@@ -0,0 +1 @@
+F.x_off{NRG_2 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1623,6,7925).lua b/Crossroads/nodes/(1623,6,7925).lua
new file mode 100644
index 0000000..5ba5cb2
--- /dev/null
+++ b/Crossroads/nodes/(1623,6,7925).lua
@@ -0,0 +1 @@
+F.x_off{NRG_3 = 1} \ No newline at end of file
diff --git a/Crossroads/nodes/(1630,6,7971).lua b/Crossroads/nodes/(1630,6,7971).lua
new file mode 100644
index 0000000..b9b4b62
--- /dev/null
+++ b/Crossroads/nodes/(1630,6,7971).lua
@@ -0,0 +1 @@
+F.x_off{NRG_5 = 1} \ No newline at end of file