aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/atc_rail.lua
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-08-11 17:42:30 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-08-11 17:42:30 +0200
commit1f6038c75a1f928951c8b4513c5c3f7615b78d99 (patch)
tree02009b5fc624a707d652fd348ea4b5abfad69c06 /advtrains_luaautomation/atc_rail.lua
parentd074d3223ac87f617b28454ef0880c04ce89d53b (diff)
downloadadvtrains-1f6038c75a1f928951c8b4513c5c3f7615b78d99.tar.gz
advtrains-1f6038c75a1f928951c8b4513c5c3f7615b78d99.tar.bz2
advtrains-1f6038c75a1f928951c8b4513c5c3f7615b78d99.zip
Add decoupling to luaatc
Diffstat (limited to 'advtrains_luaautomation/atc_rail.lua')
-rw-r--r--advtrains_luaautomation/atc_rail.lua13
1 files changed, 13 insertions, 0 deletions
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