Exemple #1
0
        public int PushObjectEx(ScriptState luaState, object o, string metatableName)
        {
            int index;

            if (TryGetObject(luaState, o, out index))
            {
                return(index);
            }
            var uindex = AddObject(o);

            LuaCore.GetMetatable(luaState, metatableName);
            LuaCore.GetMetatable(luaState, DotNetObjectsMetatable.GlobalName);
            LuaCore.NewUserData(luaState, uindex);
            LuaCore.PushValue(luaState, -3);
            LuaCore.RemoveValue(luaState, -4);
            LuaCore.SetMetatable(luaState, -2);
            LuaCore.PushValue(luaState, -1);
            LuaCore.RawSetIndex(luaState, -3, uindex);
            LuaCore.RemoveValue(luaState, -2);
            return(uindex);
        }