equivalent of including a variable inside a string, but inside code?

Hello, this is a very stupid question. When you do things like



print("playername:" ..ply:Nick())


, it will print: playername: sackcreator54. I want to do something similar like this with code, for example



			open ..realv.. ()


Where realv is a string.

A little hard to tell what you want, but I believe you are wanting to run a function/get a variable from just a string.

If so, this is very easy. What you want to do is ‘index’ using square bracket notation.

say you had the string “variable1” that was a variable of some table that you wanted to get, you would simply do:
[lua]
print( someTable[“variable1”] );
[/lua]

If you wanted to call a function from a string, you would do the same exact thing, but use parentheses to call the function.
[lua]
someTable"function1";
[/lua]

I mean, let’s say i have a variable and I want to run a function, but there’s a loop running for all things in a table.

So, let’s say the table has a, b, c, and d. I want it to loop through all a-d, and then run their respective functions (ex. opena(), openb(), openc(), and opend()). I want to do something like open …v… (), which v equals what the table is looping through, so if it were to loop through c, i’d run: openc().