use the node's paramtype2 instead of its palette filename

to decide what the airbrush should do with it.

(that plus a few related changes allows coloredwood mod to make
the airbrush work on stairsplus cut plain wood slabs/slopes/et. al)
This commit is contained in:
Vanessa Dannenberg 2018-09-12 17:57:43 -04:00
parent ad21862eee
commit 66774213e2

@ -649,21 +649,24 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
return return
end end
if not def.palette or not (def.groups and def.groups.ud_param2_colorable > 0) then if 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
local palette = nil local palette = nil
local fdir = 0 local fdir = 0
if def.palette == "unifieddyes_palette_extended.png" then if def.paramtype2 == "color" then
palette = "extended" palette = "extended"
elseif def.palette == "unifieddyes_palette_colorwallmounted.png" then elseif def.paramtype2 == "colorwallmounted" then
palette = "wallmounted" palette = "wallmounted"
fdir = node.param2 % 8 fdir = node.param2 % 8
else elseif def.paramtype2 == "colorfacedir" then
palette = "split" palette = "split"
fdir = node.param2 % 32 fdir = node.param2 % 32
else
minetest.chat_send_player(player_name, "*** That node can't be colored -- it has an invalid color mode.")
return
end end
local idx, hue = unifieddyes.getpaletteidx(painting_with, palette) local idx, hue = unifieddyes.getpaletteidx(painting_with, palette)
@ -686,6 +689,7 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
local name = def.airbrush_replacement_node or node.name local name = def.airbrush_replacement_node or node.name
if palette == "split" then if palette == "split" then
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 oldcolor = "snozzberry"
@ -701,16 +705,20 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
newcolor = "grey" newcolor = "grey"
end end
local s = string.sub(def.palette, 21) if def.airbrush_replacement_node then
oldcolor = string.sub(s, 1, string.find(s, "s.png")-1) oldcolor = "grey"
else
local s = string.sub(def.palette, 21)
oldcolor = string.sub(s, 1, string.find(s, "s.png")-1)
end
end end
if newcolor == "spring" then newcolor = "aqua" if newcolor == "spring" then newcolor = "aqua"
elseif newcolor == "azure" then newcolor = "skyblue" elseif newcolor == "azure" then newcolor = "skyblue"
elseif newcolor == "rose" then newcolor = "redviolet" elseif newcolor == "rose" then newcolor = "redviolet"
end end
name = modname..":"..string.gsub(nodename2, oldcolor, newcolor) name = modname..":"..string.gsub(nodename2, oldcolor, newcolor)
if not minetest.registered_items[name] then 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.") minetest.chat_send_player(player_name, "*** "..string.sub(painting_with, 5).." can't be applied to that node.")
return return
@ -858,22 +866,22 @@ function unifieddyes.show_airbrush_form(player)
local last_right_click = unifieddyes.player_last_right_clicked[player_name] local last_right_click = unifieddyes.player_last_right_clicked[player_name]
if last_right_click then if last_right_click then
if last_right_click.def and last_right_click.def.palette then if last_right_click.def and last_right_click.def.paramtype2 then
if last_right_click.def.palette == "unifieddyes_palette_colorwallmounted.png" then if last_right_click.def.paramtype2 == "colorwallmounted" then
nodepalette = "wallmounted" nodepalette = "wallmounted"
elseif last_right_click.def.palette == "unifieddyes_palette_extended.png" then elseif last_right_click.def.paramtype2 == "color" then
t[#t+1] = "label[0.5,8.25;(Right-clicked a node that supports all 256 colors, showing them all)]" t[#t+1] = "label[0.5,8.25;(Right-clicked a node that supports all 256 colors, showing them all)]"
showall = true showall = true
elseif last_right_click.def.palette ~= "unifieddyes_palette_extended.png" then elseif last_right_click.def.paramtype2 == "colorfacedir" then
nodepalette = "split" nodepalette = "split"
elseif not string.find(last_right_click.def.palette, "unifieddyes_palette_") then
t[#t+1] = "label[0.5,8.25;(Right-clicked a node not supported by the Airbrush, showing all colors)]"
end end
else
t[#t+1] = "label[0.5,8.25;(Right-clicked a non-colorable node, showing all colors)]"
end end
end end
if not last_right_click.def.groups or not last_right_click.def.groups.ud_param2_colorable then
t[#t+1] = "label[0.5,8.25;(Right-clicked a node not supported by the Airbrush, showing all colors)]"
end
for v = 0, 6 do for v = 0, 6 do
local val = unifieddyes.VALS_EXTENDED[v+1] local val = unifieddyes.VALS_EXTENDED[v+1]
@ -996,7 +1004,7 @@ function unifieddyes.show_airbrush_form(player)
t[#t+1] = "button_exit[11,8;2,1;cancel;Cancel]button_exit[13,8;2,1;accept;Accept]" t[#t+1] = "button_exit[11,8;2,1;cancel;Cancel]button_exit[13,8;2,1;accept;Accept]"
if last_right_click and last_right_click.def and last_right_click.def.palette and nodepalette ~= "extended" then if last_right_click and last_right_click.def and nodepalette ~= "extended" then
if showall then if showall then
t[#t+1] = "button[0.5,8;2,1;show_avail;Show Available]" t[#t+1] = "button[0.5,8;2,1;show_avail;Show Available]"
t[#t+1] = "label[2.5,8.25;(Currently showing all 256 colors)]" t[#t+1] = "label[2.5,8.25;(Currently showing all 256 colors)]"