diff --git a/minetest/colorspec.lua b/minetest/colorspec.lua index 3658b12..b5816ae 100644 --- a/minetest/colorspec.lua +++ b/minetest/colorspec.lua @@ -255,9 +255,9 @@ end --> hex string, omits alpha if possible (if opaque) function colorspec:to_string() if self.a == 255 then - return ("%02X02X02X"):format(self.r, self.g, self.b) + return ("%02X%02X%02X"):format(self.r, self.g, self.b) end - return ("%02X02X02X02X"):format(self.r, self.g, self.b, self.a) + return ("%02X%02X%02X%02X"):format(self.r, self.g, self.b, self.a) end function colorspec:to_number() diff --git a/test.lua b/test.lua index 34d776f..2efc621 100644 --- a/test.lua +++ b/test.lua @@ -267,6 +267,7 @@ test_from_string("aliceblue#42", 0xf0f8ff42) test_from_string("#333", 0x333333FF) test_from_string("#694269", 0x694269FF) test_from_string("#11223344", 0x11223344) +assert(colorspec.from_string"#694269":to_string() == "694269") local function test_logfile(reference_strings) local logfile = persistence.lua_log_file.new(mod.get_resource"logfile.test.lua", {}, reference_strings)