mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2024-12-24 17:50:29 +01:00
colorfdir -> is_color_fdir
(preparing for later inclusion of some kind of wallmounted palette)
This commit is contained in:
parent
e146c55ca0
commit
aef03c1932
21
init.lua
21
init.lua
@ -132,7 +132,7 @@ end
|
|||||||
|
|
||||||
-- code borrowed from cheapie's plasticbox mod
|
-- code borrowed from cheapie's plasticbox mod
|
||||||
|
|
||||||
function unifieddyes.getpaletteidx(color, colorfdir)
|
function unifieddyes.getpaletteidx(color, is_color_fdir)
|
||||||
local origcolor = color
|
local origcolor = color
|
||||||
local aliases = {
|
local aliases = {
|
||||||
["pink"] = "light_red",
|
["pink"] = "light_red",
|
||||||
@ -184,7 +184,7 @@ function unifieddyes.getpaletteidx(color, colorfdir)
|
|||||||
local idx
|
local idx
|
||||||
|
|
||||||
if grayscale[color] then
|
if grayscale[color] then
|
||||||
if colorfdir then
|
if is_color_fdir then
|
||||||
return (grayscale[color] * 32), 0
|
return (grayscale[color] * 32), 0
|
||||||
else
|
else
|
||||||
return grayscale[color], 0
|
return grayscale[color], 0
|
||||||
@ -208,7 +208,7 @@ function unifieddyes.getpaletteidx(color, colorfdir)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if hues[color] and shades[shade] then
|
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]
|
return (hues[color] * 8 + shades[shade]), hues[color]
|
||||||
else
|
else
|
||||||
return (shades[shade] * 32), hues[color]
|
return (shades[shade] * 32), hues[color]
|
||||||
@ -218,12 +218,17 @@ end
|
|||||||
|
|
||||||
function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
|
function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||||
local prevdye
|
local prevdye
|
||||||
|
|
||||||
|
print(dump(oldmetadata))
|
||||||
|
|
||||||
if oldmetadata and oldmetadata.fields then
|
if oldmetadata and oldmetadata.fields then
|
||||||
prevdye = oldmetadata.fields.dye
|
prevdye = oldmetadata.fields.dye
|
||||||
end
|
end
|
||||||
|
|
||||||
local inv = digger:get_inventory()
|
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 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
|
if inv:room_for_item("main", prevdye) then
|
||||||
inv:add_item("main", prevdye)
|
inv:add_item("main", prevdye)
|
||||||
@ -233,7 +238,7 @@ function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
|
|||||||
end
|
end
|
||||||
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()
|
local name = player:get_player_name()
|
||||||
if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
|
if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
|
||||||
minetest.record_protection_violation(pos,name)
|
minetest.record_protection_violation(pos,name)
|
||||||
@ -241,7 +246,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
|
|||||||
end
|
end
|
||||||
local name = stack:get_name()
|
local name = stack:get_name()
|
||||||
local pos2 = unifieddyes.select_node(pointed_thing)
|
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
|
if paletteidx then
|
||||||
|
|
||||||
@ -263,7 +268,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
|
|||||||
end
|
end
|
||||||
node.param2 = paletteidx
|
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)
|
local oldnode = minetest.get_node(pos)
|
||||||
|
|
||||||
@ -277,7 +282,7 @@ function unifieddyes.on_rightclick(pos, node, player, stack, pointed_thing, newn
|
|||||||
end
|
end
|
||||||
|
|
||||||
if newnode then -- this path is used when the calling mod want to supply a replacement node
|
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 ~=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
|
||||||
if hue ~= 0 then -- the player's wielding a colored dye
|
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)
|
minetest.swap_node(pos, node)
|
||||||
else -- this path is used when you're just painting an existing node, rather than replacing one.
|
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 is_color_fdir then
|
||||||
if oldhue then
|
if oldhue then
|
||||||
if hue ~= 0 then
|
if hue ~= 0 then
|
||||||
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..HUES[hue])
|
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..HUES[hue])
|
||||||
|
Loading…
Reference in New Issue
Block a user