-
Lua Eval
In javascript there is an eval() function that changes a string to an expression such as eval("alert('hi')") which triggers an alert.
I'm trying to find a way of doing the same in lua. I've tried using _G[x] but this doesn't work for table values (e.g x = "a.b") or functions.
Any suggestions would be much appreciated thanks!
-
Re: Lua Eval
I've managed to find a suitable answer:
Register "raweval" in MMF2
On "raweval" Run string "e = " + MMF2StringParameter(1)
And in lua..
Code:
function eval(a)
raweval(a)
return e end
-
Re: Lua Eval
That sounds dangerous.
EDIT: That's a reply to your original post, not your solution, which is innovative, though I still can't see the need for it.
-
Re: Lua Eval
loadstr() in lua does the same as eval() in javascript, php etc. ;)