mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Add simple color validator / parser
This commit is contained in:
parent
31441a02e5
commit
09671b7ac9
1 changed files with 14 additions and 0 deletions
|
@ -405,3 +405,17 @@ function mcl_util.get_object_center(obj)
|
||||||
pos.y = pos.y + (ymax - ymin) / 2.0
|
pos.y = pos.y + (ymax - ymin) / 2.0
|
||||||
return pos
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_util.get_color(colorstr)
|
||||||
|
local mc_color = mcl_colors[colorstr:upper()]
|
||||||
|
if mc_color then
|
||||||
|
return mc_color
|
||||||
|
end
|
||||||
|
if #colorstr ~= 7 or colorstr:sub(1, 1) ~= "#"then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local hex = tonumber(colorstr:sub(2, 7), 16)
|
||||||
|
if hex then
|
||||||
|
return colorstr, hex
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue