From 788ae97ba17891aea44c81adc269c88ea6f18c90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Diego=20Mart=C3=ADnez?= Date: Sun, 27 Nov 2016 03:02:38 -0300 Subject: [PATCH] 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. --- mods/carts/cart_entity.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mods/carts/cart_entity.lua b/mods/carts/cart_entity.lua index 4301b852..a0a2d9f0 100644 --- a/mods/carts/cart_entity.lua +++ b/mods/carts/cart_entity.lua @@ -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 -- 2.25.1