mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 09:13:53 +01:00
minetest.colorspec: simpler error message
This commit is contained in:
parent
139d003742
commit
651593639c
@ -186,6 +186,7 @@ function colorspec.from_string(string)
|
|||||||
return colorspec.from_number(number * 0x100 + alpha)
|
return colorspec.from_number(number * 0x100 + alpha)
|
||||||
end
|
end
|
||||||
local hex_text = string:match("^" .. hex .. "$")
|
local hex_text = string:match("^" .. hex .. "$")
|
||||||
|
assert(hex_text, "invalid colorstring")
|
||||||
local len, num = hex_text:len(), tonumber(hex_text, 16)
|
local len, num = hex_text:len(), tonumber(hex_text, 16)
|
||||||
if len == 8 then
|
if len == 8 then
|
||||||
return colorspec.from_number(num)
|
return colorspec.from_number(num)
|
||||||
@ -209,7 +210,7 @@ function colorspec.from_string(string)
|
|||||||
r = (floor(num / (16 ^ 2)) % 16) * 17
|
r = (floor(num / (16 ^ 2)) % 16) * 17
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
error("invalid colorstring: " .. string)
|
error"invalid colorstring"
|
||||||
end
|
end
|
||||||
|
|
||||||
colorspec.from_text = colorspec.from_string
|
colorspec.from_text = colorspec.from_string
|
||||||
|
Loading…
Reference in New Issue
Block a user