summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/APIDump/main_APIDump.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/APIDump/main_APIDump.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua
index 9c4fb17f8..f77409f91 100644
--- a/MCServer/Plugins/APIDump/main_APIDump.lua
+++ b/MCServer/Plugins/APIDump/main_APIDump.lua
@@ -41,6 +41,16 @@ function Initialize(Plugin)
LOG("Initialising " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
g_PluginFolder = Plugin:GetLocalFolder();
+
+ -- Load the API descriptions from the Classes and Hooks subfolders:
+ if (g_APIDesc.Classes == nil) then
+ g_APIDesc.Classes = {};
+ end
+ if (g_APIDesc.Hooks == nil) then
+ g_APIDesc.Hooks = {};
+ end
+ LoadAPIFiles("/Classes/", g_APIDesc.Classes);
+ LoadAPIFiles("/Hooks/", g_APIDesc.Hooks);
-- dump all available API functions and objects:
-- DumpAPITxt();
@@ -57,6 +67,29 @@ end
+function LoadAPIFiles(a_Folder, a_DstTable)
+ local Folder = g_PluginFolder .. a_Folder;
+ for idx, fnam in ipairs(cFile:GetFolderContents(Folder)) do
+ local FileName = Folder .. fnam;
+ -- We only want .lua files from the folder:
+ if (cFile:IsFile(FileName) and fnam:match(".*%.lua$")) then
+ local TablesFn, Err = loadfile(FileName);
+ if (TablesFn == nil) then
+ LOGWARNING("Cannot load API descriptions from " .. FileName .. ", Lua error '" .. Err .. "'.");
+ else
+ local Tables = TablesFn();
+ for k, cls in pairs(Tables) do
+ a_DstTable[k] = cls;
+ end
+ end -- if (TablesFn)
+ end -- if (is lua file)
+ end -- for fnam - Folder[]
+end
+
+
+
+
+
function DumpAPITxt()
LOG("Dumping all available functions to API.txt...");
function dump (prefix, a, Output)