From c54e0b341a88349e1a4fc7d902fdd9d9e1a6040d Mon Sep 17 00:00:00 2001 From: Gabriel PĂ©rez-Cerezo Date: Sun, 26 Jul 2020 21:07:47 +0200 Subject: 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. --- advtrains_luaautomation/atc_rail.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'advtrains_luaautomation') 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 -- cgit v1.2.3