From 1f6038c75a1f928951c8b4513c5c3f7615b78d99 Mon Sep 17 00:00:00 2001 From: Gabriel PĂ©rez-Cerezo Date: Sun, 11 Aug 2019 17:42:30 +0200 Subject: Add decoupling to luaatc --- advtrains_luaautomation/atc_rail.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'advtrains_luaautomation') diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua index bc1e00e..89cd2c1 100644 --- a/advtrains_luaautomation/atc_rail.lua +++ b/advtrains_luaautomation/atc_rail.lua @@ -53,6 +53,19 @@ function r.fire_event(pos, evtdata) advtrains.atc.train_set_command(train, cmd, atc_arrow) return true end, + split_at_index = function(index, cmd) + if not train_id then return false end + assertt(cmd, "string") + if type(index) ~= "number" then + return false + end + local new_id = advtrains.split_train_at_index(train, index) + if new_id then + minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow) + return true + end + return false + end, set_line = function(line) if type(line)~="string" and type(line)~="number" then return false -- cgit v1.2.3