diff options
author | Alexander Harkness <bearbin@gmail.com> | 2013-07-30 16:02:20 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2013-07-30 16:02:20 +0200 |
commit | 69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda (patch) | |
tree | 5a2897f8545b9751ece63b68333ae5c6ed6ead43 | |
parent | Fixed inverted sanity check in SetGameMode() (diff) | |
download | cuberite-69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda.tar cuberite-69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda.tar.gz cuberite-69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda.tar.bz2 cuberite-69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda.tar.lz cuberite-69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda.tar.xz cuberite-69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda.tar.zst cuberite-69bb6c28e2e8f98fc1aeb2ff79a7398fbf84abda.zip |
-rw-r--r-- | MCServer/Plugins/DumpAPI/main.lua | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/MCServer/Plugins/DumpAPI/main.lua b/MCServer/Plugins/DumpAPI/main.lua new file mode 100644 index 000000000..1a6ddda31 --- /dev/null +++ b/MCServer/Plugins/DumpAPI/main.lua @@ -0,0 +1,52 @@ + +-- Global variables +PLUGIN = {}; -- Reference to own plugin object + +function Initialize(Plugin) + PLUGIN = Plugin + + Plugin:SetName("DumpAPI") + Plugin:SetVersion(1) + + PluginManager = cRoot:Get():GetPluginManager() + LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) + + -- dump all available API functions and objects: + DumpAPI(); + + return true +end + +function DumpAPI() + LOG("Dumping all available functions to API.txt..."); + function dump (prefix, a, Output) + for i, v in pairs (a) do + if (type(v) == "table") then + if (GetChar(i, 1) ~= ".") then + if (v == _G) then + LOG(prefix .. i .. " == _G, CYCLE, ignoring"); + elseif (v == _G.package) then + LOG(prefix .. i .. " == _G.package, ignoring"); + else + dump(prefix .. i .. ".", v, Output) + end + end + elseif (type(v) == "function") then + if (string.sub(i, 1, 2) ~= "__") then + table.insert(Output, prefix .. i .. "()"); + end + end + end + end + + local Output = {}; + dump("", _G, Output); + + table.sort(Output); + local f = io.open("API.txt", "w"); + for i, n in ipairs(Output) do + f:write(n, "\n"); + end + f:close(); + LOG("API.txt written."); +end |