TraceCall() public static method

expects function on top runs function on top of stack, returns values returned from function, shows traceback in case of errors
public static TraceCall ( IntPtr L, int resultCount ) : WinterSync.LuaValue[]
L System.IntPtr
resultCount int
return WinterSync.LuaValue[]
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());
        }
Example #2
0
        static LuaValue[] GetTdfTableFromString(IntPtr L, string fileString)
        {
            Lua.lua_getglobal(L, "TDFparser");    // push the parser table on the stack
            Lua.lua_getfield(L, -1, "ParseText"); // push the parse string function
            var ret = CLua.TraceCall(L, 2, new LuaString(fileString));

            LuaValue.Pop(L, 1);
            return(ret);
        }