Jump to content




term.setTextColor()


  • You cannot reply to this topic
4 replies to this topic

#1 pofferman

  • Members
  • 37 posts

Posted 05 September 2015 - 10: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:
Posted Image
So have anyone got any fix for this? (Other than using numbers instead of colors.XXX)

Edited by pofferman, 05 September 2015 - 10:17 PM.


#2 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 05 September 2015 - 10: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 by HPWebcamAble, 06 September 2015 - 01:52 AM.


#3 pofferman

  • Members
  • 37 posts

Posted 05 September 2015 - 10: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 by pofferman, 05 September 2015 - 10:49 PM.


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 September 2015 - 10: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.

#5 pofferman

  • Members
  • 37 posts

Posted 05 September 2015 - 11:02 PM

Oh yea, i forgot :) ty





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users