lua_insert() public static method

public static lua_insert ( IntPtr luaState, int newTop ) : void
luaState System.IntPtr
newTop int
return void
Beispiel #1
0
        public static int GetComponentsInParent(IntPtr L)
        {
            int result = 1;
            int count  = LuaDLL.lua_gettop(L);

            if (count == 2 &&
                LuaStatic.CheckType(L, typeof(Type), 2))
            {
                UnityEngine.GameObject obj = LuaStatic.GetObj(L, 1) as UnityEngine.GameObject;
                object      type1          = LuaStatic.GetObj(L, 2);
                Type        arg1           = LuaStatic.GetType(type1);
                IEnumerable objs           = (IEnumerable)obj.GetComponentsInParent(arg1);
                LuaDLL.lua_newtable(L);
                int num2 = 0;
                foreach (var item in objs)
                {
                    LuaStatic.addGameObject2Lua(L, (UnityEngine.Component)item, (string)type1);
                    LuaDLL.lua_pushnumber(L, (double)(++num2));
                    LuaDLL.lua_insert(L, -2);
                    LuaDLL.lua_settable(L, -3);
                }

                return(result);
            }
            if (count == 3 &&
                LuaStatic.CheckType(L, typeof(Type), 2) &&
                LuaStatic.CheckType(L, typeof(Boolean), 3))
            {
                UnityEngine.GameObject obj = LuaStatic.GetObj(L, 1) as UnityEngine.GameObject;
                object      type1          = LuaStatic.GetObj(L, 2);
                Type        arg1           = LuaStatic.GetType(type1);
                Boolean     arg2           = (Boolean)LuaStatic.GetObj(L, 3);
                IEnumerable objs           = (IEnumerable)obj.GetComponentsInParent(arg1, arg2);
                LuaDLL.lua_newtable(L);
                int num2 = 0;
                foreach (var item in objs)
                {
                    LuaStatic.addGameObject2Lua(L, (UnityEngine.Component)item, "Component");
                    LuaDLL.lua_pushnumber(L, (double)(++num2));
                    LuaDLL.lua_insert(L, -2);
                    LuaDLL.lua_settable(L, -3);
                }

                return(result);
            }
            LuaStatic.traceback(L, "count not enough");
            LuaDLL.lua_error(L);
            return(result);
        }
 public object getAsObject(IntPtr luaState, int stackPos)
 {
     if (LuaDLL.lua_type(luaState, stackPos) == LuaTypes.LUA_TTABLE && LuaDLL.luaL_getmetafield(luaState, stackPos, "__index") != LuaTypes.LUA_TNIL)
     {
         if (LuaDLL.luaL_checkmetatable(luaState, -1))
         {
             LuaDLL.lua_insert(luaState, stackPos);
             LuaDLL.lua_remove(luaState, stackPos + 1);
         }
         else
         {
             LuaDLL.lua_settop(luaState, -2);
         }
     }
     return(this.translator.getObject(luaState, stackPos));
 }
Beispiel #3
0
        public static int LoadAll(IntPtr L)
        {
            int result = 1;
            int count  = LuaDLL.lua_gettop(L);

            if (count == 3 &&
                LuaStatic.CheckType(L, typeof(String), 2) &&
                LuaStatic.CheckType(L, typeof(Type), 3))
            {
                String      arg1  = (String)LuaStatic.GetObj(L, 2);
                object      type2 = LuaStatic.GetObj(L, 3);
                Type        arg2  = LuaStatic.GetType(type2);
                IEnumerable objs  = (IEnumerable)UnityEngine.Resources.LoadAll(arg1, arg2);
                LuaDLL.lua_newtable(L);
                int num2 = 0;
                foreach (var item in objs)
                {
                    LuaStatic.addGameObject2Lua(L, (UnityEngine.Object)item, (string)type2);
                    LuaDLL.lua_pushnumber(L, (double)(++num2));
                    LuaDLL.lua_insert(L, -2);
                    LuaDLL.lua_settable(L, -3);
                }

                return(result);
            }
            if (count == 2 &&
                LuaStatic.CheckType(L, typeof(String), 2))
            {
                String      arg1 = (String)LuaStatic.GetObj(L, 2);
                IEnumerable objs = (IEnumerable)UnityEngine.Resources.LoadAll(arg1);
                LuaDLL.lua_newtable(L);
                int num2 = 0;
                foreach (var item in objs)
                {
                    LuaStatic.addGameObject2Lua(L, (UnityEngine.Object)item, "Object");
                    LuaDLL.lua_pushnumber(L, (double)(++num2));
                    LuaDLL.lua_insert(L, -2);
                    LuaDLL.lua_settable(L, -3);
                }

                return(result);
            }
            LuaStatic.traceback(L, "count not enough");
            LuaDLL.lua_error(L);
            return(result);
        }
Beispiel #4
0
        public static bool PCall(IntPtr L, int nargs, int nresult)
        {
            int msgHandlerIndex = LuaDLL.lua_gettop(L) - nargs;

            LuaDLL.lua_pushcfunction(L, LuaFuncs.msgHandler);
            LuaDLL.lua_insert(L, -nargs - 2);           //msghandler,f,nargs
            int ret = LuaDLL.lua_pcall(L, nargs, nresult, -nargs - 2);

            if (ret != LuaDLL.LUA_OK)             //msghandler,errmsg
            {
                LuaDLL.lua_remove(L, -2);
                Debug.LogError(LuaDLL.lua_tostring(L, -1));
                return(false);
            }
            LuaDLL.lua_remove(L, msgHandlerIndex);
            return(true);
        }
Beispiel #5
0
        public static int FindGameObjectsWithTag(IntPtr L)
        {
            int result = 1;
            int count  = LuaDLL.lua_gettop(L);

            String      arg1 = (String)LuaStatic.GetObj(L, 2);
            IEnumerable objs = (IEnumerable)UnityEngine.GameObject.FindGameObjectsWithTag(arg1);

            LuaDLL.lua_newtable(L);
            int num2 = 0;

            foreach (var item in objs)
            {
                LuaStatic.addGameObject2Lua(L, (UnityEngine.GameObject)item, "GameObject");
                LuaDLL.lua_pushnumber(L, (double)(++num2));
                LuaDLL.lua_insert(L, -2);
                LuaDLL.lua_settable(L, -3);
            }
            return(result);
        }
Beispiel #6
0
        public static int FindObjectsOfType(IntPtr L)
        {
            int result = 1;
            int count  = LuaDLL.lua_gettop(L);

            object      type1 = LuaStatic.GetObj(L, 2);
            Type        arg1  = LuaStatic.GetType(type1);
            IEnumerable objs  = (IEnumerable)UnityEngine.Object.FindObjectsOfType(arg1);

            LuaDLL.lua_newtable(L);
            int num2 = 0;

            foreach (var item in objs)
            {
                LuaStatic.addGameObject2Lua(L, (UnityEngine.Object)item, (string)type1);
                LuaDLL.lua_pushnumber(L, (double)(++num2));
                LuaDLL.lua_insert(L, -2);
                LuaDLL.lua_settable(L, -3);
            }
            return(result);
        }
Beispiel #7
0
        public object getAsObject(KopiLua.Lua.lua_State luaState, int stackPos)
        {
            if (LuaDLL.lua_type(luaState, stackPos) == LuaTypes.LUA_TTABLE)
            {
                if (LuaDLL.luaL_getmetafield(luaState, stackPos, "__index"))
                {
                    if (LuaDLL.luaL_checkmetatable(luaState, -1))
                    {
                        LuaDLL.lua_insert(luaState, stackPos);
                        LuaDLL.lua_remove(luaState, stackPos + 1);
                    }
                    else
                    {
                        LuaDLL.lua_settop(luaState, -2);
                    }
                }
            }
            object obj = translator.getObject(luaState, stackPos);

            return(obj);
        }
Beispiel #8
0
        public object getAsNetObject(IntPtr luaState, int stackPos)
        {
            object obj = translator.getNetObject(luaState, stackPos);

            if (obj == null && LuaDLL.lua_type(luaState, stackPos) == LuaTypes.LUA_TTABLE)
            {
                if (LuaDLL.luaL_getmetafield(luaState, stackPos, "__index"))
                {
                    if (LuaDLL.luaL_checkmetatable(luaState, -1))
                    {
                        LuaDLL.lua_insert(luaState, stackPos);
                        LuaDLL.lua_remove(luaState, stackPos + 1);
                        obj = translator.getNetObject(luaState, stackPos);
                    }
                    else
                    {
                        LuaDLL.lua_settop(luaState, -2);
                    }
                }
            }
            return(obj);
        }
Beispiel #9
0
 public static void lua_setglobal(IntPtr luaState, string name)
 {
     LuaDLL.lua_pushstring(luaState, name);
     LuaDLL.lua_insert(luaState, -2);
     LuaDLL.lua_settable(luaState, LuaIndexes.LUA_GLOBALSINDEX);
 }
Beispiel #10
0
 public void LuaInsert(int idx)
 {
     LuaDLL.lua_insert(L, idx);
 }