From: paramat Date: Mon, 19 Oct 2015 22:58:24 +0000 (+0100) Subject: Boats: Check inventory in boat.on_punch X-Git-Tag: 0.4.14~198 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f3dc78204c83e55363bcdfe40b31b33949e198a7;p=oweals%2Fminetest_game.git Boats: Check inventory in boat.on_punch If puncher inventory is full, then drop boat --- diff --git a/mods/boats/init.lua b/mods/boats/init.lua index 0fb54f1a..e17d8b1b 100644 --- a/mods/boats/init.lua +++ b/mods/boats/init.lua @@ -105,7 +105,12 @@ function boat.on_punch(self, puncher, time_from_last_punch, self.object:remove() end) if not minetest.setting_getbool("creative_mode") then - puncher:get_inventory():add_item("main", "boats:boat") + local inv = puncher:get_inventory() + if inv:room_for_item("main", "boats:boat") then + inv:add_item("main", "boats:boat") + else + minetest.add_item(self.object:getpos(), "boats:boat") + end end end end