WinterSync.LuaValue.Pop C# (CSharp) Method

Pop() public static method

public static Pop ( IntPtr L, int n ) : void
L System.IntPtr
n int
return void
        public static void Pop(IntPtr L, int n)
        {
            var top = Lua.lua_gettop(L);
            if (top < n) throw new Exception("Stack is too small to pop");
            Lua.lua_pop(L, n);
        }

Usage Example

Example #1
0
        /// <summary>
        ///gets the list of dependencies from modinfo.tdf
        /// </summary>
        string[] GetDependenciesFromTdf(string archiveName, string fileName)
        {
            var modInfoText = Archive.ExtractTextFile(archiveName, fileName);

            Lua.lua_getglobal(L, "TDFparser");                                   // push the parser table on the stack
            Lua.lua_getfield(L, -1, "ParseText");                                // push the parse string function
            var modInfoTable = CLua.TraceCall(L, 2, new LuaString(modInfoText)); // load the tdf from string
            var modInfo      = modInfoTable[0].GetField("mod");

            // get all existing "dependN" fields
            var dependencies = new List <string>();
            var n            = 0;

            while (true)
            {
                var field = modInfo.GetField("depend" + n++);
                if (field != null)
                {
                    dependencies.Add(field.ToString());
                }
                else
                {
                    break;
                }
            }
            LuaValue.Pop(L, 1);
            return(dependencies.ToArray());
        }
All Usage Examples Of WinterSync.LuaValue::Pop