diff options
Diffstat (limited to 'm4')
-rw-r--r-- | m4/init_code.lua | 96 | ||||
-rw-r--r-- | m4/nodes/(1734,26,2901).lua | 1 | ||||
-rw-r--r-- | m4/nodes/(1734,26,2935).lua | 3 | ||||
-rw-r--r-- | m4/nodes/(1937,3,5835).lua | 2 | ||||
-rw-r--r-- | m4/nodes/(2010,3,5860).lua | 22 | ||||
-rw-r--r-- | m4/nodes/(2010,3,5895).lua | 1 | ||||
-rw-r--r-- | m4/nodes/(2011,3,5835).lua | 2 | ||||
-rw-r--r-- | m4/nodes/(2013,3,5889).lua | 1 | ||||
-rw-r--r-- | m4/nodes/(4539,11,6809).lua | 2 | ||||
-rw-r--r-- | m4/nodes/(4542,11,6809).lua | 4 | ||||
-rw-r--r-- | m4/nodes/(4568,11,6809).lua | 3 |
11 files changed, 137 insertions, 0 deletions
diff --git a/m4/init_code.lua b/m4/init_code.lua new file mode 100644 index 0000000..8133311 --- /dev/null +++ b/m4/init_code.lua @@ -0,0 +1,96 @@ +--env-m4.lua +if S.trains == nil then S.trains = {} end +if S.d == nil then S.d = {} end +if S.datetime == nil then S.datetime = "" end +if S.stop_display == nil then S.stop_display = false end + +F.print = function (str) if F.debug then print("".. (str or "nil") ) end end +F.isempty = function (s) return s == nil or s == "" end +F.get_rc_safe = function() return get_rc() or "" end +F.get_line_safe = function() return get_line() or "" end +F.get_train_length_safe = function() return train_length() or 0 end +F.avg = function(t) + local sum = 0 + local count = 0 + for k,v in pairs(t) do + if type(v) == "number" then + sum = sum + v + count = count + 1 + end + end + return (sum / count) +end + +if event.init then + F.debug = true + F.printAllTrainsInfo = true + F.max_displays = 4 + F.print("Initialized") +end + +F.does_train_have_rc = function(wanted_rc) + local rc = F.get_rc_safe() + if rc:match(wanted_rc) then return true end +end + +--old splitter and cpl for demo +function F.cpllooparound(ln) + if not (event.train) then + return + end + if not (F.get_line_safe() == ln) then return end + + if "ENGINE" == F.get_rc_safe() then + atc_send("CplS0WRSM") + set_rc("") + return + end + + split_at_index(F.get_train_length_safe()-1,"A0S0") --Stopping the wagons is handled here by SO + set_rc("ENGINE") + atc_send("A1") + +end + +--new ones +function F.split_looparound(ln) + if not (event.train) then return end + if not (F.get_line_safe() == ln) then return end + + split_at_index(F.get_train_length_safe()-1,"A0S0OC") --Stopping the wagons is handled here by SO + set_rc("ENGINE") + atc_send("A1") + +end + +function F.split_looparound_left(ln) + if not (event.train) then return end + if not (F.get_line_safe() == ln) then return end + + split_at_index(F.get_train_length_safe()-1,"A0S0OL") --Stopping the wagons is handled here by SO + set_rc("ENGINE") + atc_send("A1") + +end +function F.split_looparound_right(ln) + if not (event.train) then return end + if not (F.get_line_safe() == ln) then return end + + split_at_index(F.get_train_length_safe()-1,"A0S0OR") --Stopping the wagons is handled here by SO + set_rc("ENGINE") + atc_send("A1") + +end + +function F.cpl_looparound(ln) + if not (event.train) then return end + if not (F.get_line_safe() == ln) then return end + + if "ENGINE" == F.get_rc_safe() then + atc_send("CplS0WD2RS4") + set_rc("") + return + end + +end +--end of new cpl functions diff --git a/m4/nodes/(1734,26,2901).lua b/m4/nodes/(1734,26,2901).lua new file mode 100644 index 0000000..66ba746 --- /dev/null +++ b/m4/nodes/(1734,26,2901).lua @@ -0,0 +1 @@ +F.split_looparound_left("E16")
\ No newline at end of file diff --git a/m4/nodes/(1734,26,2935).lua b/m4/nodes/(1734,26,2935).lua new file mode 100644 index 0000000..0e0dc9c --- /dev/null +++ b/m4/nodes/(1734,26,2935).lua @@ -0,0 +1,3 @@ +if atc_arrow then + F.cpl_looparound("E16") +end
\ No newline at end of file diff --git a/m4/nodes/(1937,3,5835).lua b/m4/nodes/(1937,3,5835).lua new file mode 100644 index 0000000..9b60573 --- /dev/null +++ b/m4/nodes/(1937,3,5835).lua @@ -0,0 +1,2 @@ +-- +F.cpllooparound("E16")
\ No newline at end of file diff --git a/m4/nodes/(2010,3,5860).lua b/m4/nodes/(2010,3,5860).lua new file mode 100644 index 0000000..5229dce --- /dev/null +++ b/m4/nodes/(2010,3,5860).lua @@ -0,0 +1,22 @@ +local ch = { + get = "ars_set_query", + input = "ars_set", + indicator = "ars_indicator", +} + +if event.train then + digiline_send(ch.get, "GET") + return +end + +if event.digiline then + if event.channel==ch.input then + if not atc_id then + digiline_send(ch.indicator, true) + return + end + set_rc(tostring(event.msg)) + digiline_send(ch.indicator, false) + return + end +end
\ No newline at end of file diff --git a/m4/nodes/(2010,3,5895).lua b/m4/nodes/(2010,3,5895).lua new file mode 100644 index 0000000..bb6fdaa --- /dev/null +++ b/m4/nodes/(2010,3,5895).lua @@ -0,0 +1 @@ +F.cpllooparound("E16")
\ No newline at end of file diff --git a/m4/nodes/(2011,3,5835).lua b/m4/nodes/(2011,3,5835).lua new file mode 100644 index 0000000..9b60573 --- /dev/null +++ b/m4/nodes/(2011,3,5835).lua @@ -0,0 +1,2 @@ +-- +F.cpllooparound("E16")
\ No newline at end of file diff --git a/m4/nodes/(2013,3,5889).lua b/m4/nodes/(2013,3,5889).lua new file mode 100644 index 0000000..bb6fdaa --- /dev/null +++ b/m4/nodes/(2013,3,5889).lua @@ -0,0 +1 @@ +F.cpllooparound("E16")
\ No newline at end of file diff --git a/m4/nodes/(4539,11,6809).lua b/m4/nodes/(4539,11,6809).lua new file mode 100644 index 0000000..c42277b --- /dev/null +++ b/m4/nodes/(4539,11,6809).lua @@ -0,0 +1,2 @@ +atc_set_text_outside("[E16] Personhood\nvia Grub Valley\nC&C Rail") +F.split_looparound_left("E16")
\ No newline at end of file diff --git a/m4/nodes/(4542,11,6809).lua b/m4/nodes/(4542,11,6809).lua new file mode 100644 index 0000000..67b31a2 --- /dev/null +++ b/m4/nodes/(4542,11,6809).lua @@ -0,0 +1,4 @@ +-- Poor Man's ARS +if event.train and get_rc() == "E16_poor_mans_ars" then + set_route("Btw-E16-behelf", "E16Turnback") +end
\ No newline at end of file diff --git a/m4/nodes/(4568,11,6809).lua b/m4/nodes/(4568,11,6809).lua new file mode 100644 index 0000000..0e0dc9c --- /dev/null +++ b/m4/nodes/(4568,11,6809).lua @@ -0,0 +1,3 @@ +if atc_arrow then + F.cpl_looparound("E16") +end
\ No newline at end of file |