summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-28 18:18:27 -0500
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-28 18:18:27 -0500
commitaef03c1932e77291bfab153ee041164e17ecdc43 (patch)
treeb3305b80ec537f8f7fd12bf77bc36d371511c286
parente146c55ca0ad166000d0c89004ecb5fc37fb6075 (diff)
downloadunifieddyes-aef03c1932e77291bfab153ee041164e17ecdc43.tar
unifieddyes-aef03c1932e77291bfab153ee041164e17ecdc43.tar.gz
unifieddyes-aef03c1932e77291bfab153ee041164e17ecdc43.tar.bz2
unifieddyes-aef03c1932e77291bfab153ee041164e17ecdc43.tar.xz
unifieddyes-aef03c1932e77291bfab153ee041164e17ecdc43.zip
colorfdir -> is_color_fdir
(preparing for later inclusion of some kind of wallmounted palette)
-rw-r--r--init.lua21
1 files changed, 13 insertions, 8 deletions
diff --git a/init.lua b/init.lua
index 0143dc2..f802968 100644
--- a/init.lua
+++ b/init.lua
@@ -132,7 +132,7 @@ end
-- code borrowed from cheapie's plasticbox mod
-function unifieddyes.getpaletteidx(color, colorfdir)
+function unifieddyes.getpaletteidx(color, is_color_fdir)
local origcolor = color
local aliases = {
["pink"] = "light_red",
@@ -184,7 +184,7 @@ function unifieddyes.getpaletteidx(color, colorfdir)
local idx
if grayscale[color] then
- if colorfdir then
+ if is_color_fdir then
return (grayscale[color] * 32), 0
else
return grayscale[color], 0
@@ -208,7 +208,7 @@ function unifieddyes.getpaletteidx(color, colorfdir)
end
if hues[color] and shades[shade] then
- if not colorfdir then
+ if not is_color_fdir then
return (hues[color] * 8 + shades[shade]), hues[color]
else
return (shades[shade] * 32), hues[color]
@@ -218,12 +218,17 @@ end
function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
local prevdye
+
+ print(dump(oldmetadata))
+
if oldmetadata and oldmetadata.fields then
prevdye = oldmetadata.fields.dye
end
local inv = digger:get_inventory()
+ print(dump(prevdye))
+
if prevdye and not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
if inv:room_for_item("main", prevdye) then
inv:add_item("main", prevdye)
@@ -233,7 +238,7 @@ function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
end
end
-function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newnode, colorfdir)
+function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newnode, is_color_fdir)
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)
@@ -241,7 +246,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
end
local name = stack:get_name()
local pos2 = unifieddyes.select_node(pointed_thing)
- local paletteidx, hue = unifieddyes.getpaletteidx(name, colorfdir)
+ local paletteidx, hue = unifieddyes.getpaletteidx(name, is_color_fdir)
if paletteidx then
@@ -263,7 +268,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
end
node.param2 = paletteidx
- local oldpaletteidx, oldhuenum = unifieddyes.getpaletteidx(prevdye, colorfdir)
+ local oldpaletteidx, oldhuenum = unifieddyes.getpaletteidx(prevdye, is_color_fdir)
local oldnode = minetest.get_node(pos)
@@ -277,7 +282,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
end
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 is_color_fdir then -- we probably need to change the hue of the node too
if oldhue ~=0 then -- it's colored, not grey
if oldhue ~= nil then -- it's been painted before
if hue ~= 0 then -- the player's wielding a colored dye
@@ -301,7 +306,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
minetest.swap_node(pos, node)
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.
- if colorfdir then
+ if is_color_fdir then
if oldhue then
if hue ~= 0 then
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..HUES[hue])