function colorchk(color, defultcolor)
-- checks to see if color given is a number then check if its a valid color number
if type(color) == "number" then
for i = 0, 15, 1 do
if (2^i) == color then
return color
else
return defultcolor
end
end
-- if color is not a number it compairs the string values for the color number
elseif type(color) == "string" then
if color == "white" then
return colors.white
elseif color == "orange" then
return colors.orange
elseif color == "magenta" then
return colors.magenta
elseif color == "lightBlue" then
return colors.lightBlue
elseif color == "yellow" then
return colors.yellow
elseif color == "lime" then
return colors.lime
elseif color == "pink" then
return colors.pink
elseif color == "gray" or color == "grey" then
return colors.gray
elseif color == "lightGray" or color == "lightGrey" then
return colors.lightGray
elseif color == "cyan" then
return colors.cyan
elseif color == "purple" then
return colors.purple
elseif color == "blue" then
return colors.blue
elseif color == "brown" then
return colors.brown
elseif color == "green" then
return colors.green
elseif color == "red" then
return colors.red
elseif color == "black" then
return colors.black
end
-- sets color to background color if it fails
else
return defultcolor
end
end
if I do colorchk(1,2) I get attempt to index nil if I run it in the lua test area and 2 if I store it in a function.but for an example If I get and output for the following
colorchk("red", 128) output: 128 (should be 16384)
colorchk(colors.red, 128) output same as above
colorchk(nil, 128) output 128 in (this case it should be 128)
this may just be a simple error in my if statments.