37 posts
Posted 05 September 2015 - 11:08 PM
Hey guys, i have a problem with this
term.setTextColor("colors.blue")
the reason why i have written "colors.blue" in Quotes, is that i have loaded the text from a config file.
The error code looks like this:
So have anyone got any fix for this? (Other than using numbers instead of colors.XXX)
Edited on 05 September 2015 - 09:17 PM
957 posts
Location
Web Development
Posted 05 September 2015 - 11:30 PM
Just save the actual color in the file, not 'colors.<color>'
Like this:
blue
Then you'd access it like this:
colorString = "blue"
term.setTextColor( colors[ colorString ] )
(Obviously this isn't loading a file, I'm assuming you can get the string from the file into a variable)
EDIT: Oops, should have been 'colors', not 'color'
Edited on 06 September 2015 - 12:52 AM
37 posts
Posted 05 September 2015 - 11:48 PM
So you mean i should make a table with all the colors? e.g.
local color = {["blue"] = 2048} --2048 = colors.blue
local a = "blue"
term.setTextColor(color[a])
or what do you mean? i have the color in a variable. Could you show a bit of code, for an example?
Thanks
Edited on 05 September 2015 - 09:49 PM
8543 posts
Posted 05 September 2015 - 11:53 PM
There already is a table with all the colors, that's one of the things in the colors API (which is a table). So you'd just save the text "blue" in the file, then use that to index into the colors API.
37 posts
Posted 06 September 2015 - 12:02 AM
Oh yea, i forgot :)/> ty