Skip to content

Commit

Permalink
Carts: Take creative mode into account
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kaeza authored and paramat committed Nov 28, 2016
1 parent 1a6ad49 commit 788ae97
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mods/carts/cart_entity.lua
Expand Up @@ -91,9 +91,13 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
end
end

local leftover = puncher:get_inventory():add_item("main", "carts:cart")
if not leftover:is_empty() then
minetest.add_item(self.object:getpos(), leftover)
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
minetest.add_item(self.object:getpos(), leftover)
end
end
self.object:remove()
return
Expand Down

0 comments on commit 788ae97

Please sign in to comment.