From ab39853d9378e8dc43f7bc2c8f51b2a5092d2dbe Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 26 Jan 2013 03:44:09 +0000 Subject: Added a function to dump all available Lua API functions into the Debuggers plugin. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1173 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/Debuggers/Debuggers.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index f2f3f9570..a619e0b0a 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -1,6 +1,7 @@ -- Global variables PLUGIN = {} -- Reference to own plugin object +ShouldDumpFunctions = false -- If set to true, all available functions are logged upon plugin initialization @@ -17,6 +18,28 @@ function Initialize(Plugin) PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE) LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) + + -- dump all available functions to console: + if (ShouldDumpFunctions) then + LOG("Dumping all available functions:"); + function dump (prefix, a) + for i, v in pairs (a) do + if (type(v) == "table") 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) + end + elseif (type(v) == "function") then + LOG(prefix .. i .. "()") + end + end + end + dump("", _G); + end + return true end -- cgit v1.2.3