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.
This commit is contained in:
Vanessa Dannenberg 2019-09-15 23:36:49 -04:00
parent 0082b1513a
commit 9271f07f12
1 changed files with 7 additions and 3 deletions

View File

@ -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