10-08-2015, 09:13 AM
(10-08-2015, 07:09 AM)xoft Wrote: Heh, the web handler structure seems familiar, I suppose You cloned it off one of my plugins - Gallery, GalExport, or my additions to the Core?
heh, yeah. I was lazy & tierd at that time, sorry
And thanks for the warm welcome 
(10-08-2015, 06:17 AM)NiLSPACE Wrote:cPluginManager:ForEachPlugin( function(a_Plugin) if (not cFile:Exists(a_Plugin:GetLocalFolder() .. "/Info.lua")) then -- The plugin doesn't have a Info.lua file return false end local PluginInfoLoader = loadfile(a_Plugin:GetLocalFolder() .. "/Info.lua") local LoaderEnv = {} -- This way the function can't overwrite any of the functions in this environment. -- And we can extract the g_PluginInfo variable setfenv(PluginInfoLoader, LoaderEnv) local PluginInfo = LoaderEnv["g_PluginInfo"] local PluginName = PluginInfo.Name -- You can also use a_Plugin:GetName() of course. -- For each command like usually. for CommandString, CommandInfo in pairs(PluginInfo.Commands) do ins(Row, "<tr></td><td valign='top'>" .. CommandString .. "<br/></td><td valign='top'>" .. (CommandInfo.Permission or "") .. "<br/></td><td valign='top'>" .. (CommandInfo.HelpString or "") .. "<br/></td><td valign='top'></tr>") end end )Keep in mind that I haven't tested thisIt could fail miserably.
I believe the prettifier escaped some single quotes. You probably need to fix that before testing
The code should work, but its just the setfenv(function, table) that isn't working properly, It always prints an empty table

I also made a failstate, so it doesn't puke out errors.
local function GetPlugins()
local Row = {}
-- Lets grab all plugin permission, commands and help string
cPluginManager:ForEachPlugin(
function(a_Plugin)
if (not cFile:IsFile(a_Plugin:GetLocalFolder() .. "/Info.lua")) then
-- The plugin doesn't have a Info.lua file
return false
end
local PluginInfoLoader = loadfile(a_Plugin:GetLocalFolder() .. "/Info.lua")
local LoaderEnv = {}
-- This way the function can't overwrite any of the functions in this environment.
-- And we can extract the g_PluginInfo variable
setfenv(PluginInfoLoader, LoaderEnv)
local PluginInfo = LoaderEnv["g_PluginInfo"]
-- Instead of puking out errors, lets do a failstate
-- by making everything "Invalid"
if PluginInfo == nil then
ins(LoaderEnv, {
["g_PluginInfo"] =
{
Name = "Invalid",
Commands = {
["/example"] =
{
Permission = "example.core",
Handler = HandleInvalid,
HelpString = "Invalid",
},
["/another_example"] =
{
Permission = "example.another",
Handler = HandleInvalid,
HelpString = "Another Invalid",
},
}
}
})
PluginInfo = LoaderEnv[1]["g_PluginInfo"]
end
local PluginName = PluginInfo.Name -- You can also use a_Plugin:GetName() of course.
-- For each command like usually.
for CommandString, CommandInfo in pairs(PluginInfo.Commands) do
ins(Row, "<tr></td><td valign='top'>" .. CommandString .. "<br/></td><td valign='top'>" .. (CommandInfo.Permission or "") .. "<br/></td><td valign='top'>" .. (CommandInfo.HelpString or "") .. "<br/></td><td valign='top'></tr>")
end
end
)
return con(Row)
end


It could fail miserably.