HelpSystem plugin

Posted by Ked on Wed 09 Nov 2005 10:21 AM — 2 posts, 12,101 views.

Russia #0
Trying to get a grip on Lua I've written this thing to provide a central access point for help pages of all plugins installed in a world. After installing type "#help" and it should bring up a menu of plugins, after that typing "#help <menu_number>" will display the description for the corresponding plugin. The output is in no way formatted, so it might not look too good unless you take care to format the descriptions of your plugins for presentation inside Mushclient.



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- MuClient version 3.68 -->

<!-- Plugin "HelpSystem" generated by Plugin Wizard -->

<muclient>
<plugin
   name="HelpSystem"
   author="Ked"
   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>
Australia Forum Administrator #1
Yep, seems to work as advertised! Thanks. :)