This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Inumel's profile picture

Expected number

Started by Inumel, 11 May 2013 - 12:53 AM
Inumel #1
Posted 11 May 2013 - 02:53 AM
Hi! me again :)/>

I am trying to make a program that outputs a word of the users choice, in whatever color they want

Here is my code


word = ""
print("What word do you want to display?")
word = read()
print("What color do you want the text to be?")
color = read()
term.setTextColor("colors." .. color)
print(word)

i am getting the error Expected number when attempting to term.setTextColor

The way I wrote that, it should work i would think?
Engineer #2
Posted 11 May 2013 - 03:09 AM
For the colors part; you cannot use a string. You should use colors['blue'] for example
Mads #3
Posted 11 May 2013 - 03:38 AM
Or you could use this(not best solution):

term.setTextColor(loadstring("return colors." .. color)())