summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-26 07:10:48 -0500
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-26 07:10:48 -0500
commit4f1303aac16696097776b3e55a0e26f6703d0572 (patch)
treebf68e891c6d9485bb8138c0445223f364769f6f3
parent1773af6868878f240a70b624be1fa27e7024c644 (diff)
downloadunifieddyes-4f1303aac16696097776b3e55a0e26f6703d0572.tar
unifieddyes-4f1303aac16696097776b3e55a0e26f6703d0572.tar.gz
unifieddyes-4f1303aac16696097776b3e55a0e26f6703d0572.tar.bz2
unifieddyes-4f1303aac16696097776b3e55a0e26f6703d0572.tar.xz
unifieddyes-4f1303aac16696097776b3e55a0e26f6703d0572.zip
handle special cases for greyscale dyes and unpainted nodes
-rw-r--r--init.lua27
1 files changed, 22 insertions, 5 deletions
diff --git a/init.lua b/init.lua
index 9f29697..d2ff67a 100644
--- a/init.lua
+++ b/init.lua
@@ -191,8 +191,7 @@ function unifieddyes.on_destruct(pos)
end
end
-function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newnode)
- local colorfdir = (minetest.registered_nodes[minetest.get_node(pos).name].paramtype2 == "colorfacedir")
+function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newnode, colorfdir)
local name = player:get_player_name()
if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
minetest.record_protection_violation(pos,name)
@@ -222,13 +221,31 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
if newnode then
node.name = newnode
- if colorfdir then -- we probably need to change the color 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
- node.name = string.gsub(node.name, "_"..HUES[oldhue], "_"..HUES[hue])
+ print("at line 226")
+ print("prevdye = "..dump(prevdye))
+ print("oldhue = "..dump(oldhue).." "..dump(HUES[oldhue]))
+ print("hue = "..dump(hue).." "..dump(HUES[hue]))
+ print("node.name = "..dump(node.name))
+ if oldhue ~= nil then -- it's been painted before
+ if hue ~= 0 then -- the player's wielding a colored dye
+ node.name = string.gsub(node.name, "_"..HUES[oldhue], "_"..HUES[hue])
+ else -- it's a greyscale dye
+ node.name = string.gsub(node.name, "_"..HUES[oldhue], "_grey")
+ end
+ else -- it's never had a color at all
+ if hue ~= 0 then -- and if the wield is greyscale, don't change the node name
+ node.name = string.gsub(node.name, "_grey", "_"..HUES[hue])
+ end
+ end
else
- node.name = string.gsub(node.name, "_grey", "_"..HUES[hue])
+ if hue ~= 0 then -- greyscale dye on greyscale node = no hue change
+ node.name = string.gsub(node.name, "_grey", "_"..HUES[hue])
+ end
end
end
+
minetest.swap_node(pos, node)
else
if colorfdir then -- we probably need to change the color of the node too