I am trying to make a method that evaluates a string and returns a LuaFunction object for the function contained in it. These strings will be input by a user so I can't know the names of the functions beforehand. Example string:
function doSomething()
print('x')
end
I want the LuaFunction to point to doSomething
.
I was able to use a regex to capture the name of the function and then use NLua.Lua.GetFunction but that didn't work with functions in functions.
Right now my code uses KeraLua.Lua.LoadString and returns a LuaFunction for the chunk created by LoadString. This sort of works but it means the LuaFunction can't take args.
This answer is similar to what I want, but I can't force the functions to be members of a table like it shows.