Boats: Check inventory in boat.on_punch
authorparamat <mat.gregory@virginmedia.com>
Mon, 19 Oct 2015 22:58:24 +0000 (23:58 +0100)
committerparamat <mat.gregory@virginmedia.com>
Mon, 19 Oct 2015 23:26:30 +0000 (00:26 +0100)
If puncher inventory is full, then drop boat

mods/boats/init.lua

index 0fb54f1ac2ce6c6a01a1c104712fe930a17e92aa..e17d8b1b78addbbb777b2316ba966e417d00248a 100644 (file)
@@ -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