Codebase list minetest-mod-unifieddyes / 64cf927
New upstream version 20190915.3 Julien Puydt 4 years ago
2 changed file(s) with 15 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
1111 paramtype2 = "color",
1212 palette = "unifieddyes_palette_extended.png",
1313 groups = {snappy = 1, cracky = 2, ud_param2_colorable = 1}
14 airbrush_replacement_node = "mymod:my_other_colored_node"
14 airbrush_replacement_node = "mymod:my_other_colored_node",
15 on_dig = unifieddyes.on_dig
1516 })
1617 ```
1718
3334 `airbrush_replacement_node`: The node to swap in when the airbrush is used on this node. For example, you could `minetest.override_item()` on some default node to add this field, pointing to a colorable node of your own, so that when the default node is painted, it's replaced with yours in the new color.
3435
3536 #### Function calls
37
38 **`unifieddyes.on_dig(pos, node, digger)`**
39
40 Set in a node definition's `on_dig` callback, this makes sure that if the player digs a neutral node, i.e. a colorable node that was left uncolored/white after placing, they receive a version of that item that has been stripped of its itemstack color setting, so that it is identical to what would have been in their inventory when that node was originally placed. This prevents the engine splitting stacks of that item due to technically-different but visually-identical itemstack coloring. This function is only needed in the definition of colorable versions of a node, not any uncolored counterparts. For example, if you have a mod that has a simple, wooden chair, and the mod turns it into one with a colored seat cushion when you airbrush or craft it with dye, then only that latter colored-seat version needs this function.
3641
3742 **`unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)`
3843 `unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing)`**
119124
120125 Does just what it sounds like - it registers all the nodes that are needed for a given base node (`def`) to be able to use the split palette, each named according to `name`, with the palette hue appended. If a custom drop is needed, it can be passed along (only a string is allowed here, specifying a single item).
121126
122
123127 #### Tables
124128
125129 In addition to the above API calls, Unified Dyes provides several useful tables
143147 ```lua
144148 place_param2 = 240,
145149 after_dig_node = unifieddyes.after_dig_node,
146 after_place_node = unifieddyes.recolor_on_place,
147 ud_replacement_node = "mod:some_node"
150 ud_replacement_node = "mod:some_node",
151 on_dig = unifieddyes.on_dig
148152 ```
149153
150154 * Add the `airbrush_replacement_node` key to the node definition, if needed.
196196
197197 -- The complementary function: strip-off the color if the node being dug is still white/neutral
198198
199 local function move_item(item, pos, inv)
200 if not creative_mode or not inv:contains_item("main", item, true) then
199 local function move_item(item, pos, inv, digger)
200 local creative = creative_mode or minetest.check_player_privs(digger, "creative")
201 if inv:room_for_item("main", item)
202 and (not creative or not inv:contains_item("main", item, true)) then
201203 inv:add_item("main", item)
204 elseif not creative then
205 minetest.item_drop(item, digger, pos)
202206 end
203207 minetest.remove_node(pos)
204208 end
226230 local inv = digger:get_inventory()
227231
228232 if del_color then
229 if inv:room_for_item("main", node.name) then move_item(node.name, pos, inv) end
233 move_item(node.name, pos, inv, digger)
230234 else
231235 return minetest.node_dig(pos, node, digger)
232236 end