From 1c5d79800fc82b2c257945394337d56dcb9b1b4d Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Thu, 26 Jan 2017 13:42:36 -0500 Subject: [PATCH] add an alternate "find HSV" function. Note that if the result is greyscale, the name ("black", "grey", ...) is returned in the "hue" field, sat is empty string, and val is "light", "dark", or empty string. --- init.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/init.lua b/init.lua index c6a03ae..e7eea42 100644 --- a/init.lua +++ b/init.lua @@ -97,6 +97,33 @@ function unifieddyes.is_buildable_to(placer_name, ...) return true end +function unifieddyes.get_hsv(name) + local hue = "" + local a,b + for _, i in ipairs(HUES) do + a,b = string.find(name, "_"..i) + if a and not ( string.find(name, "_redviolet") and i == "red" ) then + hue = i + break + end + end + + if string.find(name, "grey") then hue = "grey" + elseif string.find(name, "white") then hue = "white" + elseif string.find(name, "black") then hue = "black" + end + + local sat = "" + if string.find(name, "_s50") then sat = "_s50" end + + local val = "" + if string.find(name, "dark_") then val = "dark_" end + if string.find(name, "medium_") then val = "medium_" end + if string.find(name, "light_") then val = "light_" end + + return hue, sat, val +end + -- code borrowed from cheapie's plasticbox mod function unifieddyes.getpaletteidx(color, colorfdir)