Carts: Take creative mode into account

This commit makes the carts mod not add the cart
item to the player's inventory if running with
creative mode and the player already has it.
This commit is contained in:
Diego Martínez 2016-11-27 03:02:38 -03:00 committed by paramat
parent 1a6ad498d7
commit 788ae97ba1

View File

@ -91,10 +91,14 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
end end
end end
local leftover = puncher:get_inventory():add_item("main", "carts:cart") local inv = puncher:get_inventory()
if not minetest.setting_getbool("creative_mode")
or not inv:contains_item("main", "carts:cart") then
local leftover = inv:add_item("main", "carts:cart")
if not leftover:is_empty() then if not leftover:is_empty() then
minetest.add_item(self.object:getpos(), leftover) minetest.add_item(self.object:getpos(), leftover)
end end
end
self.object:remove() self.object:remove()
return return
end end