From 2ea4a8cff1d8e335fda472e4c7988424ca522610 Mon Sep 17 00:00:00 2001 From: orwell Date: Tue, 6 Feb 2024 23:06:38 +0100 Subject: Add chatcommand and luaatc function to get global_slowdown --- advtrains_luaautomation/environment.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'advtrains_luaautomation/environment.lua') diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua index d85bedc..9fcba1d 100644 --- a/advtrains_luaautomation/environment.lua +++ b/advtrains_luaautomation/environment.lua @@ -164,6 +164,9 @@ local static_env = { return false end end, + get_slowdown = function() + return advtrains.global_slowdown + end } -- If interlocking is present, enable route setting functions -- cgit v1.2.3 From b28ceaa2b48f39855183b982c9668d0154a626df Mon Sep 17 00:00:00 2001 From: gpcf Date: Sun, 14 May 2023 19:48:30 +0200 Subject: Add register_function command so mods can register their own functons, low-level interface for departure boards --- advtrains_luaautomation/environment.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'advtrains_luaautomation/environment.lua') diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua index 9fcba1d..6df5248 100644 --- a/advtrains_luaautomation/environment.lua +++ b/advtrains_luaautomation/environment.lua @@ -262,6 +262,11 @@ if advtrains.lines then } end + +atlatc.register_function = function (name, f) + static_env[name] = f +end + for _, name in pairs(safe_globals) do static_env[name] = _G[name] end -- cgit v1.2.3 From 7c4f1377e452134ab9e4addd0f01360dfa72564a Mon Sep 17 00:00:00 2001 From: Blockhead Date: Wed, 5 Jun 2024 04:09:04 +1000 Subject: Fix section_occupancy: Return empty table Fixes the functioning of the LuaATC function section_occupancy in the presence of no trains. Currently, if there is no train in the section, advtrains.interlocking.db.get_ts will return a table with a nil entry. When that nil value is passed to table.copy, Minetest throws out an error. Instead of passing nil to table.copy, just make a new empty table. --- advtrains_luaautomation/environment.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'advtrains_luaautomation/environment.lua') diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua index 6df5248..761e227 100644 --- a/advtrains_luaautomation/environment.lua +++ b/advtrains_luaautomation/environment.lua @@ -233,7 +233,7 @@ if advtrains.interlocking then ts_id = tostring(ts_id) local response = advtrains.interlocking.db.get_ts(ts_id) if not response then return false end - return table.copy(response.trains) + return (response.trains and table.copy(response.trains)) or {} end end -- cgit v1.2.3 From 216f28e51aa3f8fea78f4fc054cb1071f3a9ce72 Mon Sep 17 00:00:00 2001 From: Maverick2797 Date: Tue, 7 May 2024 20:58:26 +0800 Subject: Fix set_aspect() Actually send aspect to advtrains.interlocking.signal_set_aspect() from LuaATC set_aspect() --- advtrains_luaautomation/environment.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'advtrains_luaautomation/environment.lua') diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua index 761e227..ee7628d 100644 --- a/advtrains_luaautomation/environment.lua +++ b/advtrains_luaautomation/environment.lua @@ -224,7 +224,7 @@ if advtrains.interlocking then end static_env.set_aspect = function(signal, asp) local pos = atlatc.pcnaming.resolve_pos(signal) - return advtrains.interlocking.signal_set_aspect(pos) + return advtrains.interlocking.signal_set_aspect(pos,asp) end --section_occupancy() -- cgit v1.2.3 From 852e2f4219c4e7a9bebf7b27bb1c026f98719f97 Mon Sep 17 00:00:00 2001 From: Maverick2797 Date: Fri, 30 Aug 2024 17:25:01 +0800 Subject: LuaATC add trainparts(train_id) Returns a copy of the trainparts table to allow tracking individual wagon ids Also fixed a couple of file permissions from previous commits --- advtrains_luaautomation/README.md | 3 +++ advtrains_luaautomation/environment.lua | 6 ++++++ advtrains_luaautomation/operation_panel.lua | 0 3 files changed, 9 insertions(+) mode change 100755 => 100644 advtrains_luaautomation/operation_panel.lua (limited to 'advtrains_luaautomation/environment.lua') diff --git a/advtrains_luaautomation/README.md b/advtrains_luaautomation/README.md index 0bf56bb..f98f7a0 100644 --- a/advtrains_luaautomation/README.md +++ b/advtrains_luaautomation/README.md @@ -93,6 +93,9 @@ Removes any pending interrupts of this node. Make this active component send a digiline message on the specified channel. Not available in init code. + - `trainparts(train_id)` + returns a table with the ids of the cars the train is composed of, or false if `train_id` is invalid. `train_id` can be replaced with `atc_id` when used in LuaATC Rails. + - `atc_send_to_train(, )` Sends the specified ATC command to the train specified by its train id. This happens regardless of where the train is in the world, and can be used to remote-control trains. Returns true on success. If the train ID does not exist, returns false and does nothing. See [atc_command.txt](../atc_command.txt) for the ATC command syntax. diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua index ee7628d..b54d45c 100644 --- a/advtrains_luaautomation/environment.lua +++ b/advtrains_luaautomation/environment.lua @@ -153,6 +153,12 @@ local static_env = { local pos=atlatc.pcnaming.resolve_pos(parpos, "interrupt_pos") atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg}) end, + train_parts = function(train_id) + if not train_id then return false end + local train = advtrains.trains[train_id] + if not train then return false end + return table.copy(train.trainparts or {}) + end, -- sends an atc command to train regardless of where it is in the world atc_send_to_train = function(train_id, command) assertt(command, "string") diff --git a/advtrains_luaautomation/operation_panel.lua b/advtrains_luaautomation/operation_panel.lua old mode 100755 new mode 100644 -- cgit v1.2.3