예제 #1
0
        /// <summary>
        /// Registers a .net method denoted by the delegate Lua.LuaFunction as a lua function
        /// the function will take on the name luaFuncName, in lua
        /// </summary>
        /// <param name="func">.net function to register with lua</param>
        /// <param name="luaFuncName">name of .net function in lua</param>
        public void RegisterLuaFunction(Lua.LuaFunction func, string luaFuncName)
        {
            Lua.lua_pushcfunction(L, func);
            Lua.lua_setglobal(L, luaFuncName);
            //Lua.lua_register(m_lua_State, luaFuncName, func);

            //make sure the delegate callback is not collected by the garbage collector before
            //unmanaged code has called back
            m_refs.Add(func);
        }