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

execute a string as a command

Started by JPGTA, 08 July 2012 - 12:48 AM
JPGTA #1
Posted 08 July 2012 - 02:48 AM
is it possible to turn a string into a command, and then save the output of that command back into a string? for example:

a=read()
a1=("colors."..a)
I want it to run the string "colors.a" and then print the string it outputs to another variable.
KaoS #2
Posted 08 July 2012 - 06:44 AM
in this case just use:


local a=read()
local colorcode=colors[a]

the colors command is actually just a table so yeah. other examples are a little harder, try posting your script. then we can help you better
JPGTA #3
Posted 08 July 2012 - 07:04 AM
Ah, Thank you, that helped, I was just trying to make a basic script using read and color to help me understand how the colors api works.
KaoS #4
Posted 08 July 2012 - 07:29 AM
ah ok, so you could input as many colours as you liked and see the output, cool