The same question already asked here
Lua: Executing a string and storing the output of the command in a variable
But I want the function loadstring somehow return the result in string form that may be assigned to a string variable later to use further, what it returns is a function. Below code is an example:
ret = assert(loadstring(str_cmd))()
ret is a function:(
How can I get the REPL/loadstring output in string form?
str_cmdand your expected result. - Yu Hao