Allow only boat driver to be detached from boat (fixes #276)

This commit is contained in:
BlockMen 2014-10-03 03:20:31 +02:00
parent 7f44a49d99
commit 349a63ed14

@ -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 if not puncher or not puncher:is_player() or self.removed then
return return
end end
puncher:set_detach() if self.driver and puncher == self.driver then
default.player_attached[puncher:get_player_name()] = false self.driver = nil
puncher:set_detach()
self.removed = true default.player_attached[puncher:get_player_name()] = false
-- delay remove to ensure player is detached end
minetest.after(0.1, function() if not self.driver then
self.object:remove() self.removed = true
end) -- delay remove to ensure player is detached
if not minetest.setting_getbool("creative_mode") then minetest.after(0.1, function()
puncher:get_inventory():add_item("main", "boats:boat") self.object:remove()
end)
if not minetest.setting_getbool("creative_mode") then
puncher:get_inventory():add_item("main", "boats:boat")
end
end end
end end