The most commen way to store colors in Lua is using tables, like this
Code:
local color = { r = 1, b = 0.5, g = 0.75 }
Although I prefer this way, because it works with unpack()
Code:
local color = { 1, 0.5, 0.75 }
But I've been thinking, wouldn't storing colors in a single number be more efficient, as that would use no tables. Then you just have to throw them through a function like this to get the rgb values.
Code:
function DecodeColor(color)
local r = bit.band(bit.rshift(color,16),255);
local g = bit.band(bit.rshift(color,8),255);
local b = bit.band(color,255);
return r / 255, g / 255, b / 255;
end
print(DecodeColor(0xff80c0))