From 9271f07f12dcf7f5c5c312209cc318834cf5ba84 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Sun, 15 Sep 2019 23:36:49 -0400 Subject: [PATCH] fix incorrect drop behavior when stipping bogus color in the case of full inv. Should be the same as normal Minetest behavior now: In survival mode, the node is deleted, then: * If there is room in your inv, you get whatever the node would normally give you. * If there's no room, the node drops to the ground as an item entity. In creative mode, the node is deleted, then: * If you don't already have one of the item, you get one. * If you already have one, or if there's no room in your inventory, "you'll get nothing and LIKE it!" :-) Also: made sure to check for creative priv as well as proper creative mode. --- init.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index ca3912d..b87ff45 100644 --- a/init.lua +++ b/init.lua @@ -197,9 +197,13 @@ minetest.register_on_placenode( -- The complementary function: strip-off the color if the node being dug is still white/neutral -local function move_item(item, pos, inv) - if not creative_mode or not inv:contains_item("main", item, true) then +local function move_item(item, pos, inv, digger) + local creative = creative_mode or minetest.check_player_privs(digger, "creative") + if inv:room_for_item("main", item) + and (not creative or not inv:contains_item("main", item, true)) then inv:add_item("main", item) + elseif not creative then + minetest.item_drop(item, digger, pos) end minetest.remove_node(pos) end @@ -227,7 +231,7 @@ function unifieddyes.on_dig(pos, node, digger) local inv = digger:get_inventory() if del_color then - if inv:room_for_item("main", node.name) then move_item(node.name, pos, inv) end + move_item(node.name, pos, inv, digger) else return minetest.node_dig(pos, node, digger) end