mt-mods / unifieddyes

GNU General Public License v2.0
0 stars 4 forks source link

fix logic of unifieddyes.on_dig to conform w/ documentation #15

Closed fluxionary closed 10 months ago

fluxionary commented 11 months ago

currently, there's logic errors in unifieddyes.on_dig. per the documentation,

    on_dig = function(pos, node, digger),
    -- default: minetest.node_dig
    -- By default checks privileges, wears out item (if tool) and removes node.
    -- return true if the node was dug successfully, false otherwise.
    -- Deprecated: returning nil is the same as returning true.

currently, that function sometimes returns nil on failure, sometimes returns nil on success, and sometimes returns the value of minetest.dig_node. this breaks some code i'm writing for my replacer redo, which attempts to not allow the replacer to change the colors of nodes. it also fails to do the other things that minetest.dig_node does, e.g. wear out the tool and call various callbacks.

in this PR, i've copied out the code for minetest.node_dig into a separate function that differs only in that it doesn't ask the lua API to generate the drops, and instead just uses the item without the palette_index metadata.

OgelGames commented 11 months ago

This seems like a lot of extra code to fix a small bug 🤔

fluxionary commented 10 months ago

This seems like a lot of extra code to fix a small bug 🤔

if you've got a suggestion for how to get the proper functionality with less code, i'm all ears. i'm somewhat annoyed i had to copy most of that function myself, and upstream could possibly change in the future.