GetLoadedPlugins

From LoTROInterface Wiki

Jump to: navigation, search


Gets the plugins that are currently loaded.

Syntax

Lua
function PluginManager.GetLoadedPlugins();

Returns

Type: Object
Returns a table containing the currently loaded plugins

Remarks

The table returned by the function is a Lua dictionary with paired keys and values. The number of key/value pairs for each table entry depend on the data in each plugin's definition file. If a plugin definition file is missing a key's value then the corresponding table entry will be missing.

Possible keys

Key name Value description
Image Path to the image used for this plugin. The path must use forward slashes (/). Example: <Image>MyPlugins/PluginName/Resources/icon.tga</Image>
Description Description of the plugin created by the author. This value can be used to display multiple lines.
Version Version displayed in the Plugin Manager.
Package The name of the lua file that the plugin manager loads to "activate" the plugin.
Author The authors name provided in the plugin definition file.
Name The name displayed for the plugin when loaded into the plugin manager or when using the "/plugins list" command. Note that the name of the plugin can differ from the folder name where the plugin resides.
ScriptState The lua apartment name where the plugin is loaded. Plugins that share the same ScriptState (ie. same apartment name) will be unloaded when that apartment is unloaded. If the ScriptState value is left empty then the plugin is loaded as a "global" plugin. Global plugins are unloaded when the Lotro client is closed or when the "Unload All" button is pressed in the plugin manager. Additional information about the ScriptState can be found in the lotro forum post Writing LoTRO Lua Plugins for Noobs.


Example usage #1 - List all plugins and their definition information

aTableResult = Turbine.PluginManager:GetLoadedPlugins();
for aKey,aValue in ipairs(aTableResult) do
  if (type(aValue)=="table") then
    Turbine.Shell.WriteLine( aKey .. ")" );
    for k, bStr in pairs(aValue) do
      if (type(bStr)=="string") then
        Turbine.Shell.WriteLine( "    " .. k .. ": " .. bStr );
      else
        Turbine.Shell.WriteLine( "    " .. k .. ": Type=" .. type(bStr)  );
      end
    end -- for
  else
    if (type(aValue)=="string") then
      Turbine.Shell.WriteLine( aKey .. ") " .. aValue .. " " );
    else
      Turbine.Shell.WriteLine( aKey .. ") Type=" .. type(aValue) .. " " );
    end 
  end
end

The above code outputs all plugins and their definition values in the lotro client chat window. The example below shows a plugin that is missing the "Image" and "description" key values:

 
1)
    Version: 1.0b
    Package: CryoflamePlugins.CryoflameExample.Main
    Author: Mr. Cryoflame
    Name: Cryoflame Example plugin
    ScriptState: Default

Example usage #2 - Get value for a named key

aTableResult = Turbine.PluginManager:GetLoadedPlugins();
Turbine.Shell.WriteLine( aTableResult[1]["Name"] );

The code above outputs to the console the "Name" value for the first loaded plugin.

Personal tools