// This is a LuaCLRFunction // It allows you to interact with the stack directly // similarly to lua_CFunction, *but* it comes with // built in proper error handling (which means you // can safely throw inside here) public static int TestFunction(LuaState lua) { lua.CheckArg(LuaType.String, 1); lua.CheckArg(LuaType.Number, 2); lua.CheckArg(LuaType.Boolean, 3); var arg1 = lua.ToString(1); var arg2 = lua.ToLong(2); var arg3 = lua.ToBool(3); if (arg1 != "hello" || arg2 != 1000 || arg3 != false) { throw new InvalidOperationException("Wrong password!"); } lua.PushString("Hello, world!"); return(1); }