<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="HelpSystem"
   author="Keldar"
   id="4436c2b199a520b71736d800"
   language="Lua"
   purpose="Organizing the presentation of plugin help pages"
   save_state="y"
   date_written="2005-11-09"
   requires="3.65"
   version="1.1"
   >
<description trim="y">
<![CDATA[
Help system

#help      -   brings up a menu of available pages
#help n    -   display help for plugin number n
]]>
</description>

</plugin>


<aliases>
<alias name="HelpMenu" match="#help" send_to="12" enabled="y"><send>DisplayMenu()</send></alias>
<alias name="HelpEntry" match="^[#]help ([0-9]+)$" send_to="12" enabled="y" regexp="y">
	<send>DisplayHelpFile(%1)</send></alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
function getIDs()
    local idList = {}
    for k,v in pairs(GetPluginList()) do
        idList[v] = GetPluginInfo(v,1)
    end
    return idList
end


menu = {}

function DisplayMenu(...)
    menu = {}
    local idList = getIDs()
    AnsiNote(ANSI(37,1,44), "PLUGIN HELP FILE INDEX\n")
    
    AnsiNote(ANSI(37), "To view the help file of a plugin type #HELP, followed by the menu number of that plugin.\n")
    
    local c = 1
    for k,v in pairs(idList) do
	local name = v
	AnsiNote(" ", ANSI(37), tostring(c), ") ", name)
	menu[c] = k
	c= c + 1
    end
    AnsiNote("\n", ANSI(0))
end

function DisplayHelpFile(num)
    if menu[num] == nil then
        AnsiNote(ANSI(37), "Unable to find menu entry " .. tostring(num))
        return
    end
    local name = GetPluginInfo(menu[num], 1)
    AnsiNote(ANSI(37,1,44), "HELP FOR PLUGIN: " .. string.upper(name) .. "\n")
    AnsiNote(ANSI(37), GetPluginInfo(menu[num], 3) .. "\n")

end
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="HelpSystem:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>
