Fix colorspec:to_string()

This commit is contained in:
Lars Mueller 2021-11-13 23:38:58 +01:00
parent 2d47f5fd9f
commit 9a70d4cc98

@ -290,10 +290,11 @@ end
--> hex string, omits alpha if possible (if opaque) --> hex string, omits alpha if possible (if opaque)
function colorspec:to_string() function colorspec:to_string()
if self.a == 255 then if self.a == 255 then
return ("%02X%02X%02X"):format(self.r, self.g, self.b) return ("#%02X%02X%02X"):format(self.r, self.g, self.b)
end end
return ("%02X%02X%02X%02X"):format(self.r, self.g, self.b, self.a) return ("#%02X%02X%02X%02X"):format(self.r, self.g, self.b, self.a)
end end
metatable.__tostring = colorspec.to_string
--! This is not a Minetest-accepted number, use :to_number_argb() instead --! This is not a Minetest-accepted number, use :to_number_argb() instead
function colorspec:to_number() function colorspec:to_number()