I'm using the loadstring function, but I do not know if this is the right way:
a= "st = {b=1, c=2}"
st = {}
b = loadstring(a)
b()
print(st.b)
Is there any simpler way?
I'm using the loadstring function, but I do not know if this is the right way:
a= "st = {b=1, c=2}"
st = {}
b = loadstring(a)
b()
print(st.b)
Is there any simpler way?
If you do not need to create the global variable st
, use
b = loadstring("return {b=1, c=2}")()
If you want to do this many times, consider something like
function eval(x)
return loadstring("return "..x)()
end