Chapter 13. Plugins

Plugins extend the functionality of KildClient. They add more features that make the client even more powerful.

Basically, plugins can define triggers, aliases, macros and timers and/or new functions. Whenever the plugin is loaded, the new functionality is available.

You can work with plugins from the World Editor (see Chapter 4). Open the World Editor, and select the Plugins section inside Automation. You will see a screen like this:

Figure 13-1. The Plugin list

There are two lists in the window: one lists the plugins that are currently loaded and that can be used. The other lists the plugins in the startup list, which are plugins that are loaded automatically for you whenever you connect to the World.

To load a plugin, press the Load button. A dialog will be opened for you to select the file. Select the file and press Open. The plugin will be loaded and will appear in the list. Or, if there was a problem and the plugin could not be loaded, the reason will be given in a message box.

While selecting the file, you have the option to specify that the plugin is to be loaded always at startup (that is, when you connect to the World). If you select that option, the plugin will also be added to the other list.

You can get help for a loaded plugin by selecting its line and pressing the Help button. Some help describing how to use the plugin will be shown in the main World window.

You can disable a plugin that is loaded. When a plugin is disabled, it is turned off temporarily. To disable a plugin, select its line in the list of loaded plugins and click the check box in the Enabled column. To enable it back, click in the check box again.

To add a plugin that is to be loaded always at startup (without loading it now, or if it is already loaded), press the Add button after the list of the startup plugins. A dialog box will open for you to select the file, and if that file could be loaded, the plugin will be added to the list.

To remove a plugin so that it is not loaded anymore at startup, select its line and press Remove. And to change the order that the plugins are loaded, select the line and use the Up and Down buttons to move the plugin.

13.1. Loading Plugins from the Command Line

It is also possible to load plugins directly from the command line, for those more comfortable with it and with Perl.

To load a plugin, the $world->loadplugin function is used. It must be called with one argument, which can be either the full path to the file that defines the plugin, or just the plugin name. But for this to work, the file must be installed in one of the directories that KildClient looks for plugins. By default, two locations are searched for: one is the plugins directory under KildClient's directory in your HOME path (that is, ~/.kildclient/plugins in UNIX systems). The other is the plugins directory under the directory where KildClient stores some of its files (generally it is something like /usr/local/share/kildclient/plugins).

For example, here is how to load the keypad plugin (which is a standard plugin distributed with KildClient):

Example 13-1. Loading a plugin


$world->loadplugin('keypad')

As an additional example, the code below loads a plugin specifying its full filename:

Example 13-2. Loading a plugin specifying the full filename


$world->loadplugin('/home/joe/kildclient-plugins/attackplugin.pl')

Either way, you should see a message saying that the plugin has been loaded. It is now already working. If the plugin was already loaded, loading will fail.

To always load the plugin when you connect to the World, either use the World Editor as described above, or add the line that loads it to your script file. See Section 4.4.1.

13.1.1. Enabling and Disabling Plugins

If you want to turn off a plugin temporarily, you can disable it. Later, when you want it to work again, just reenable it.

To disable a plugin, use the $world->displugin function, passing as argument the name of the plugin. What this function does is disable the plugin's triggers, aliases, macros and timers. You can still call the plugin functions directly.

To enable a plugin again, use the $world->enaplugin function, passing as argument the name of the plugin.