Beispiel #1
0
        public static int CheckUObject(this LuaState state, int index, string name)
        {
            IntPtr udata = state.CheckUData(index, name);

            if (udata == IntPtr.Zero)
            {
                return(-1);
            }

            return(Marshal.ReadInt32(udata));
        }
Beispiel #2
0
        public static int ToNetObject(this LuaState state, int index, IntPtr tag)
        {
            if (state.Type(index) != LuaType.UserData)
            {
                return(-1);
            }

            IntPtr userData;

            if (state.CheckMetaTable(index, tag))
            {
                userData = state.ToUserData(index);
                if (userData != IntPtr.Zero)
                {
                    return(Marshal.ReadInt32(userData));
                }
            }

            userData = state.CheckUData(index, "luaNet_class");
            if (userData != IntPtr.Zero)
            {
                return(Marshal.ReadInt32(userData));
            }

            userData = state.CheckUData(index, "luaNet_searchbase");
            if (userData != IntPtr.Zero)
            {
                return(Marshal.ReadInt32(userData));
            }

            userData = state.CheckUData(index, "luaNet_function");
            if (userData != IntPtr.Zero)
            {
                return(Marshal.ReadInt32(userData));
            }

            return(-1);
        }