handle a few more color-to-grey and grey-to-color cases

This commit is contained in:
Vanessa Ezekowitz 2017-01-26 11:23:18 -05:00
parent 3f7fb1af74
commit b1ad76ab72

@ -230,7 +230,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
end end
end end
if newnode then if newnode then -- this path is used when the calling mod want to supply a replacement node
if colorfdir then -- we probably need to change the hue of the node too if colorfdir then -- we probably need to change the hue of the node too
if oldhue ~=0 then -- it's colored, not grey if oldhue ~=0 then -- it's colored, not grey
if oldhue ~= nil then -- it's been painted before if oldhue ~= nil then -- it's been painted before
@ -252,20 +252,26 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
end end
node.name = newnode node.name = newnode
minetest.swap_node(pos, node) minetest.swap_node(pos, node)
else else -- this path is used when you're just painting an existing node, rather than replacing one.
newnode = oldnode -- note that here, newnode/oldnode are a full node, not just the name. newnode = oldnode -- note that here, newnode/oldnode are a full node, not just the name.
if colorfdir then if colorfdir then
print("prevdye = "..dump(prevdye)) print("prevdye = "..dump(prevdye))
print("hue = "..dump(hue).." "..dump(HUES[hue])) print("hue = "..dump(hue).." "..dump(HUES[hue]))
print("newnode.name = "..newnode.name) print("newnode.name = "..newnode.name)
if oldhue then if oldhue then
if hue ~= 0 then
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..HUES[hue]) newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..HUES[hue])
else
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_grey")
end
elseif string.find(minetest.get_node(pos).name, "_grey") and hue ~= 0 then
newnode.name = string.gsub(newnode.name, "_grey", "_"..HUES[hue])
end end
end end
newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 32) newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 32)
minetest.set_node(pos, newnode) minetest.set_node(pos, newnode)
end end
else else -- here is where a node is just being placed, not something being colored
if unifieddyes.is_buildable_to(player:get_player_name(), pos2) and if unifieddyes.is_buildable_to(player:get_player_name(), pos2) and
minetest.registered_nodes[name] then minetest.registered_nodes[name] then
local placeable_node = minetest.registered_nodes[stack:get_name()] local placeable_node = minetest.registered_nodes[stack:get_name()]