/// <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()); }
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); }