diff options
Diffstat (limited to 'Crossroads')
-rw-r--r-- | Crossroads/init_code.lua | 46 | ||||
-rw-r--r-- | Crossroads/nodes/(1538,6,7946).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1554,6,7941).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1610,6,7934).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1610,6,7943).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1611,6,7941).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1612,6,7941).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1612,6,7942).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1612,6,7949).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1617,6,7943).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1623,6,7925).lua | 1 | ||||
-rw-r--r-- | Crossroads/nodes/(1630,6,7971).lua | 1 |
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 |