mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2025-06-28 06:20:36 +02:00
Compare commits
5 Commits
2019-07-18
...
2019-09-22
Author | SHA1 | Date | |
---|---|---|---|
c6883a8300 | |||
22dc40cacc | |||
9271f07f12 | |||
0082b1513a | |||
d59ccd3298 |
12
API.md
12
API.md
@ -12,7 +12,8 @@ minetest.register_node("mymod:colored_node", {
|
||||
paramtype2 = "color",
|
||||
palette = "unifieddyes_palette_extended.png",
|
||||
groups = {snappy = 1, cracky = 2, ud_param2_colorable = 1}
|
||||
airbrush_replacement_node = "mymod:my_other_colored_node"
|
||||
airbrush_replacement_node = "mymod:my_other_colored_node",
|
||||
on_dig = unifieddyes.on_dig
|
||||
})
|
||||
```
|
||||
|
||||
@ -35,6 +36,10 @@ If your node if of the kind where you need the split palette, but you need to pu
|
||||
|
||||
#### Function calls
|
||||
|
||||
**`unifieddyes.on_dig(pos, node, digger)`**
|
||||
|
||||
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.
|
||||
|
||||
**`unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)`
|
||||
`unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing)`**
|
||||
|
||||
@ -120,7 +125,6 @@ Makes a colored itemstack out of the given `itemstack` and `color` (as a dye, e.
|
||||
|
||||
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).
|
||||
|
||||
|
||||
#### Tables
|
||||
|
||||
In addition to the above API calls, Unified Dyes provides several useful tables
|
||||
@ -144,8 +148,8 @@ If your mod used the old paradigm where you craft a neutral-colored item, place
|
||||
```lua
|
||||
place_param2 = 240,
|
||||
after_dig_node = unifieddyes.after_dig_node,
|
||||
after_place_node = unifieddyes.recolor_on_place,
|
||||
ud_replacement_node = "mod:some_node"
|
||||
ud_replacement_node = "mod:some_node",
|
||||
on_dig = unifieddyes.on_dig
|
||||
```
|
||||
|
||||
* Add the `airbrush_replacement_node` key to the node definition, if needed.
|
||||
|
10
init.lua
10
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(ItemStack(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
|
||||
|
Reference in New Issue
Block a user