aboutsummaryrefslogtreecommitdiff
path: root/couple.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-09-29 08:20:06 +0200
committerorwell96 <mono96.mml@gmail.com>2016-09-29 08:20:06 +0200
commitbb50b390d4b0669718eb9872d294256e026b42ca (patch)
tree2c3808b05f289b9da538d37a3b0120a078b0e4e9 /couple.lua
parent2d59119e372996adeda7e37ae61f899e170d3514 (diff)
downloadadvtrains-bb50b390d4b0669718eb9872d294256e026b42ca.tar.gz
advtrains-bb50b390d4b0669718eb9872d294256e026b42ca.tar.bz2
advtrains-bb50b390d4b0669718eb9872d294256e026b42ca.zip
add owner system to prevent random train destroying
Diffstat (limited to 'couple.lua')
-rw-r--r--couple.lua19
1 files changed, 18 insertions, 1 deletions
diff --git a/couple.lua b/couple.lua
index 5e6d81b..a846c8b 100644
--- a/couple.lua
+++ b/couple.lua
@@ -26,9 +26,26 @@ minetest.register_entity("advtrains:discouple", {
self.object:remove()
return
end
+ self.object:set_armor_groups({immortal=1})
end,
get_staticdata=function() return "DISCOUPLE" end,
- on_punch=function(self)
+ on_punch=function(self, player)
+ --only if player owns at least one wagon next to this
+ local own=player:get_player_name()
+ if self.wagon.owner and self.wagon.owner~=own then
+ local train=advtrains.trains[self.wagon.train_id]
+ local nextwgn_id=train.trainparts[self.wagon.pos_in_trainparts-1]
+ for aoi, le in pairs(minetest.luaentities) do
+ if le and le.is_wagon then
+ if le.unique_id==nextwgn_id then
+ if le.owner and le.owner~=own then
+ minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.")
+ return
+ end
+ end
+ end
+ end
+ end
advtrains.split_train_at_wagon(self.wagon)--found in trainlogic.lua
end,
on_step=function(self, dtime)