From 349a63ed14bfaaf06bfe856045bfdd49fb55ef8e Mon Sep 17 00:00:00 2001 From: BlockMen Date: Fri, 3 Oct 2014 03:20:31 +0200 Subject: [PATCH] Allow only boat driver to be detached from boat (fixes #276) --- mods/boats/init.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mods/boats/init.lua b/mods/boats/init.lua index 12126988..0c657207 100644 --- a/mods/boats/init.lua +++ b/mods/boats/init.lua @@ -80,16 +80,20 @@ function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d if not puncher or not puncher:is_player() or self.removed then return end - puncher:set_detach() - default.player_attached[puncher:get_player_name()] = false - - self.removed = true - -- delay remove to ensure player is detached - minetest.after(0.1, function() - self.object:remove() - end) - if not minetest.setting_getbool("creative_mode") then - puncher:get_inventory():add_item("main", "boats:boat") + if self.driver and puncher == self.driver then + self.driver = nil + puncher:set_detach() + default.player_attached[puncher:get_player_name()] = false + end + if not self.driver then + self.removed = true + -- delay remove to ensure player is detached + minetest.after(0.1, function() + self.object:remove() + end) + if not minetest.setting_getbool("creative_mode") then + puncher:get_inventory():add_item("main", "boats:boat") + end end end -- 2.25.1