mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2024-12-25 02:00:27 +01:00
allow replacement nodes during airbrushing
This commit is contained in:
parent
414d72d2a6
commit
fa71e3166c
3
API.md
3
API.md
@ -13,6 +13,7 @@ minetest.register_node("mymod:colored_node", {
|
|||||||
palette = "unifieddyes_palette_extended.png",
|
palette = "unifieddyes_palette_extended.png",
|
||||||
groups = {snappy = 1, cracky = 2, ud_param2_colorable = 1}
|
groups = {snappy = 1, cracky = 2, ud_param2_colorable = 1}
|
||||||
on_construct = unifieddyes.on_construct,
|
on_construct = unifieddyes.on_construct,
|
||||||
|
airbrush_replacement_node = "mymod:my_other_colored_node"
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -31,6 +32,8 @@ minetest.register_node("mymod:colored_node", {
|
|||||||
|
|
||||||
`on_construct`: see below.
|
`on_construct`: see below.
|
||||||
|
|
||||||
|
`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.
|
||||||
|
|
||||||
#### Function calls
|
#### Function calls
|
||||||
|
|
||||||
**`unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)`
|
**`unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)`
|
||||||
|
6
init.lua
6
init.lua
@ -633,7 +633,7 @@ function unifieddyes.getpaletteidx(color, palette_type)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- punch-to-recolor
|
-- punch-to-recolor using the airbrush
|
||||||
|
|
||||||
function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
@ -691,7 +691,9 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = node.name, param2 = fdir + idx})
|
local name = def.airbrush_replacement_node or node.name
|
||||||
|
|
||||||
|
minetest.swap_node(pos, {name = name, param2 = fdir + idx})
|
||||||
if not creative or not creative.is_enabled_for(player_name) then
|
if not creative or not creative.is_enabled_for(player_name) then
|
||||||
inv:remove_item("main", painting_with)
|
inv:remove_item("main", painting_with)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user