SuperiorServers / dash

Collection of libraries, utilities, and core Garry's Mod changes intended to improve development of addons and gamemodes
Other
66 stars 20 forks source link

function COLOR:SetHex(hex) #10

Closed ghost closed 4 years ago

ghost commented 5 years ago

How must work this shit?

I doesn't find other way like recode this shit like

function COLOR:SetHex(hex)
    local r, g, b = string_match(hex, '#(..)(..)(..)')
    self.r, self.g, self.b = tonumber(r, 16), tonumber(g, 16), tonumber(b, 16)
    return Color(self.r, self.g, self.b)
end

instead

function COLOR:SetHex(hex)
    local r, g, b = string_match(hex, '#(..)(..)(..)')
    self.r, self.g, self.b = tonumber(r, 16), tonumber(g, 16), tonumber(b, 16)
end
Heitzz commented 4 years ago

How must work this shit?

local myHexColor = Color(255, 53, 30):ToHex() local myNormalColor = Color() myNormalColor:SetHex(myHexColor)

Example of the usage, easiest way to save the color table in MySQL.

KingofBeast commented 4 years ago

EncodedRGB/A would actually be the best method for storing in a database