aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-07-26 21:07:47 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-07-26 23:30:07 +0200
commitc54e0b341a88349e1a4fc7d902fdd9d9e1a6040d (patch)
tree356497a3b91b0f2a201984923b0bcae2acebe3be /advtrains_luaautomation
parentde8add139c44001700bd656f82c22d62480e6e8c (diff)
downloadadvtrains-c54e0b341a88349e1a4fc7d902fdd9d9e1a6040d.tar.gz
advtrains-c54e0b341a88349e1a4fc7d902fdd9d9e1a6040d.tar.bz2
advtrains-c54e0b341a88349e1a4fc7d902fdd9d9e1a6040d.zip
add split_train_at_fc luaatc command
This command splits the train at the second non-empty FC it encounters, taking with it the first few freight cars that all go to the same destination.
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--advtrains_luaautomation/atc_rail.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index 0b9c911..69c519a 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -66,6 +66,15 @@ function r.fire_event(pos, evtdata)
end
return false
end,
+ split_at_fc = function(cmd)
+ assertt(cmd, "string")
+ if not train_id then return false end
+ local new_id, fc = advtrains.split_train_at_fc(train)
+ if new_id then
+ minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow)
+ end
+ return fc
+ end,
set_shunt = function()
if not train_id then return false end
train.autocouple = true