Posted 29 July 2014 - 05:34 PM
Hey guys! I was messing around with the terminal glasses from OpenPeripheral, and I got frustrated having to look up every hex color code every time I wanted a different color. So I looked around and, HEY, someone had already made a thing for that. I looked at it and it was ok, but I didn't like that you would have to use it as such:
hexColors[colors.green]
Or something like that, I wanted to be able to just type:
hexColors.green
As it would be faster and more easily read, so I made some minor modifications to the code and here you are:
-- white, orange, magenta, lightBlue, yellow, lime, pink, gray, lightGray, cyan, purple, blue, brown, green, red, black
local defHex = { 0xFFFFFF, 0xFFA500, 0xFF00FF, 0xADD8E6, 0xFFFF00, 0x00FF00, 0xFFC0CB, 0x808080, 0xD3D3D3, 0x00FFFF, 0x800080, 0x0000FF, 0xA52A2A, 0x008000, 0xFF0000, 0x000000 }
local color
_G.hexColors = {}
for i = 1, #defHex do
color = 2^(i-1) --this line is mine, cause the other one didnt look as nice
table.insert(hexColors, color, defHex[i])
end
--this part is mine
for k,v in pairs(colors) do
hexColors[k] = hexColors[v]
hexColors[v] = nil
end
--end my part
Also, pastebin code: 1asBs5vn