From 9a70d4cc98ba26d1408fd661411908a000f09b95 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sat, 13 Nov 2021 23:38:58 +0100 Subject: [PATCH] Fix colorspec:to_string() --- minetest/colorspec.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/minetest/colorspec.lua b/minetest/colorspec.lua index ba246d9..dac0308 100644 --- a/minetest/colorspec.lua +++ b/minetest/colorspec.lua @@ -290,10 +290,11 @@ end --> hex string, omits alpha if possible (if opaque) function colorspec:to_string() 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 - 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 +metatable.__tostring = colorspec.to_string --! This is not a Minetest-accepted number, use :to_number_argb() instead function colorspec:to_number()