aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/atc_rail.lua
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-07-28 20:39:35 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-07-28 20:39:35 +0200
commit36d8c8b7162b3b6ba6cc0a7f98b0dc295024ecd8 (patch)
treee2c76537639fd20e2765e878e2475b855db2a4bb /advtrains_luaautomation/atc_rail.lua
parentc7ea09ed59d54fda9a7537dba53538ef171a7ba8 (diff)
downloadadvtrains-36d8c8b7162b3b6ba6cc0a7f98b0dc295024ecd8.tar.gz
advtrains-36d8c8b7162b3b6ba6cc0a7f98b0dc295024ecd8.tar.bz2
advtrains-36d8c8b7162b3b6ba6cc0a7f98b0dc295024ecd8.zip
Add command to split off locomotive
Diffstat (limited to 'advtrains_luaautomation/atc_rail.lua')
-rw-r--r--advtrains_luaautomation/atc_rail.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index 88203ae..758b8f9 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -73,10 +73,15 @@ function r.fire_event(pos, evtdata)
if new_id then
minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow)
end
- if fc == "" then
- return nil
- end
- return fc
+ return fc or ""
+ end,
+ split_off_locomotive = function(cmd)
+ assertt(cmd, "string")
+ if not train_id then return false end
+ local new_id, fc = advtrains.split_train_at_fc(train, true)
+ if new_id then
+ minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow)
+ end
end,
train_length = function ()
if not train_id then return false end