diff options
author | Blockhead <jbis1337@hotmail.com> | 2020-03-03 22:59:04 +1100 |
---|---|---|
committer | Blockhead <jbis1337@hotmail.com> | 2020-03-03 23:00:20 +1100 |
commit | 3b87ac5372c8efa3b8cd3f19a1fc2c9fa88341a2 (patch) | |
tree | 59a623fdd8ed509575558bb8579b5e16ed360985 | |
parent | 0689c70aaccf879e0df59aa7dbedc46be73a445f (diff) | |
download | advtrains-3b87ac5372c8efa3b8cd3f19a1fc2c9fa88341a2.tar.gz advtrains-3b87ac5372c8efa3b8cd3f19a1fc2c9fa88341a2.tar.bz2 advtrains-3b87ac5372c8efa3b8cd3f19a1fc2c9fa88341a2.zip |
Delete train if it ends up off track, show a warning
-rw-r--r-- | advtrains/copytool.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/advtrains/copytool.lua b/advtrains/copytool.lua index b188c16..dc18081 100644 --- a/advtrains/copytool.lua +++ b/advtrains/copytool.lua @@ -70,13 +70,18 @@ minetest.register_tool("advtrains:copytool", { local id=advtrains.create_new_train_at(pointed_thing.under, plconnid, 0, wagons) local train = advtrains.trains[id] + train.off_track = train.end_index<train.path_trk_b + if (train.off_track) then + minetest.chat_send_player(pname, "Back of train would end up off track, cancelling.") + advtrains.remove_train(id) + return + end train.text_outside = clipboard.text_outside train.text_inside = clipboard.text_inside train.routingcode = clipboard.routingcode train.line = clipboard.line - return itemstack - + return end) end, -- Copy: Take the pointed-at train and put it on the clipboard |