Search code examples
.netlualuainterface

Convert a string to type "LuaFunction"


I'm using the LuaInterface in .net for a large project I'm working on. Is it possible to convert a string straight into a LuaFunction (similar to how LoadString() works?).


Solution

  • LuaInterface has LoadString, that is how you get lua source code parsed into a LuaFunction, you can then use the Call method to execute the function.

    static void Main(string[] args) {
        Lua lua = new LuaInterface.Lua();
    
        LuaFunction func = lua.LoadString("return 5", "name for debugging");
    
        func.Call();
    }