mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2024-12-24 17:50:29 +01:00
handle special case of split palette with full colors in node name
also check for ud_param2_colorable before proceeding to airbrush also handle new -> old color names in split palette switching
This commit is contained in:
parent
d53fb146dd
commit
c3036aba00
4
API.md
4
API.md
@ -28,7 +28,9 @@ minetest.register_node("mymod:colored_node", {
|
|||||||
- "unifieddyes_palette_colorwallmounted.png"
|
- "unifieddyes_palette_colorwallmounted.png"
|
||||||
- or one of the "split" hues palettes (see below).
|
- or one of the "split" hues palettes (see below).
|
||||||
|
|
||||||
`groups`: If your node can be colored by punching it with dye, its groups entry must contain the key ud_param2_colorable = 1, among whatever else you'd normally put there. If the node is software-controlled, as might be the case for some mesecons-digilines aware node, then this group key should be omitted.
|
`groups`: If your node can be colored by using the airbrush, its groups entry must contain the key ud_param2_colorable = 1, among whatever else you'd normally put there. If the node is software-controlled, as might be the case for some mesecons-digilines aware node, then this group key should be omitted.
|
||||||
|
|
||||||
|
If your node if of the kind where you need the split palette, but you need to put the *full color name* into the node name, as opposed to just the hue, then add the keys `ud_color_start` and `ud_color_end` and set them to the positions of the first and last characters of the color name (where 1 is the first character of the mod name at the start of the node name, i.e. "mymod:foo_bar_orange_baz" would have the start set to 15 and the end at 20).
|
||||||
|
|
||||||
`on_construct`: see below.
|
`on_construct`: see below.
|
||||||
|
|
||||||
|
36
init.lua
36
init.lua
@ -665,7 +665,7 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not def.palette then
|
if not def.palette or not (def.groups and def.groups.ud_param2_colorable > 0) then
|
||||||
minetest.chat_send_player(player_name, "*** That node can't be colored.")
|
minetest.chat_send_player(player_name, "*** That node can't be colored.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -699,29 +699,41 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local oldidx = node.param2 - fdir
|
local oldidx = node.param2 - fdir
|
||||||
|
|
||||||
local name = def.airbrush_replacement_node or node.name
|
local name = def.airbrush_replacement_node or node.name
|
||||||
|
|
||||||
if palette == true then
|
if palette == true then
|
||||||
local s = string.sub(def.palette, 21)
|
|
||||||
local oldcolor = string.sub(s, 1, string.find(s, "s.png")-1)
|
|
||||||
|
|
||||||
local modname = string.sub(name, 1, string.find(name, ":")-1)
|
local modname = string.sub(name, 1, string.find(name, ":")-1)
|
||||||
local nodename2 = string.sub(name, string.find(name, ":")+1)
|
local nodename2 = string.sub(name, string.find(name, ":")+1)
|
||||||
|
local oldcolor = "snozzberry"
|
||||||
|
local newcolor = "razzberry" -- intentionally misspelled ;-)
|
||||||
|
|
||||||
local a,b
|
if def.ud_color_start and def.ud_color_end then
|
||||||
|
oldcolor = string.sub(node.name, def.ud_color_start, def.ud_color_end)
|
||||||
|
newcolor = string.sub(painting_with, 5)
|
||||||
|
else
|
||||||
|
if hue ~= 0 then
|
||||||
|
newcolor = unifieddyes.HUES[hue]
|
||||||
|
else
|
||||||
|
newcolor = "grey"
|
||||||
|
end
|
||||||
|
|
||||||
local newcolor = "grey"
|
local s = string.sub(def.palette, 21)
|
||||||
if hue ~= 0 then
|
oldcolor = string.sub(s, 1, string.find(s, "s.png")-1)
|
||||||
newcolor = unifieddyes.HUES[hue]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local a,b = string.gsub(nodename2, oldcolor, newcolor)
|
if newcolor == "spring" then newcolor = "aqua"
|
||||||
name = modname..":"..a
|
elseif newcolor == "azure" then newcolor = "skyblue"
|
||||||
|
elseif newcolor == "rose" then newcolor = "redviolet"
|
||||||
|
end
|
||||||
|
|
||||||
|
name = modname..":"..string.gsub(nodename2, oldcolor, newcolor)
|
||||||
|
if not minetest.registered_items[name] then
|
||||||
|
minetest.chat_send_player(player_name, "*** "..string.sub(painting_with, 5).." can't be applied to that node.")
|
||||||
|
return
|
||||||
|
end
|
||||||
elseif idx == oldidx then
|
elseif idx == oldidx then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = name, param2 = fdir + idx})
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user