I am trying to make code that takes a string, such as "red" and turns it into a color in the colors API. So far I've come up with something like this:
local color = "red"
color = "colors."..color
-- put code here that turns the string "colors.red" into the actual API reference colors.red
term.setTextColor(color)
print("test")
What I want is for the terminal to print "test" in red text but I can't do that without turning the string into a function or API reference (or whatever it's called). I've tried using loadstring to convert it but it always returns as nil.
local redAsString = "red"
local redAsColour = colours[redAsString]
term.setTextColor(redAsColour )
print("test")
Lupus590 it works now, thanks!