using UniLua; // create a new Lua interpreter state LuaState lua = new LuaState(); // load a Lua script lua.L_DoFile("example.lua"); // get a reference to a Lua function lua.GetGlobal("myFunction"); // call the Lua function with one argument lua.PushString("hello"); lua_pcall(lua, 1, 0, 0);
using UniLua; // create a new Lua interpreter state LuaState lua = new LuaState(); // load a Lua script lua.L_DoFile("example.lua"); // get a reference to a Lua function lua.GetGlobal("myFunction"); // call the Lua function with error handling and custom message int res = lua_pcall(lua, 0, 0, 0); if (res != LuaDef.LUA_OK) { // get the error message from the stack and print it string errorMsg = lua.ToString(-1); Console.WriteLine("Error: " + errorMsg); lua.Pop(1); }Package library: UniLua.