PluginInstance is the object that represents a single plugin, or the schema. Plugin.include creates one for every plugin with the info from its plugin.yml and exposes it as the PLUGIN global while the plugin's files are included; the schema's instance is the SCHEMA global. The functions a plugin defines on this object become its hook handlers once it is registered. The setters are meant to be called from the plugin's main file, and PluginInstance:set_global gives the plugin a global name of its own.

Summary

Methods

Converts the plugin to a string of the form '#Plugin:name'.
Returns the author of the plugin.
Returns the description of the plugin.
Returns the folder that contains the plugin's code.
Returns the name of the plugin.
Returns the path the plugin was included from.
Class constructor.
Checks whether this plugin object is the schema.
Registers the plugin with the Plugin library.
Sets the author of the plugin.
Merges the fields of a table into the plugin object.
Sets the description of the plugin.
Makes the plugin available as a global variable, unless a global table with that name already exists.
Sets the name of the plugin.

Methods

PluginInstance:__tostring()

shared lib/plugin_instance.lua:104

Converts the plugin to a string of the form '#Plugin:name'.

Returns

  • String

PluginInstance:get_author()

shared lib/plugin_instance.lua:46

Returns the author of the plugin.

Returns

  • String

PluginInstance:get_description()

shared lib/plugin_instance.lua:52

Returns the description of the plugin.

Returns

  • String

PluginInstance:get_folder()

shared lib/plugin_instance.lua:34

Returns the folder that contains the plugin's code.

Returns

  • String

PluginInstance:get_name()

shared lib/plugin_instance.lua:28

Returns the name of the plugin.

Returns

  • String

PluginInstance:get_path()

shared lib/plugin_instance.lua:40

Returns the path the plugin was included from. Plugins are stored under this path.

Returns

  • String

PluginInstance:init(id, data)

shared lib/plugin_instance.lua:15

Class constructor. Fills in the basic plugin fields, then merges the whole data table into the object.

Parameters

  • id String plugin ID; data.id is used if this is nil
  • data Map plugin info with name, author, folder, path, description and any additional fields

PluginInstance:is_schema()

shared lib/plugin_instance.lua:98

Checks whether this plugin object is the schema.

Returns

  • Boolean true for the schema, nil for regular plugins

PluginInstance:register()

shared lib/plugin_instance.lua:110

Registers the plugin with the Plugin library.

See also

PluginInstance:set_author(author)

shared lib/plugin_instance.lua:64

Sets the author of the plugin.

Parameters

  • author String new author; the current author is kept if this is nil

PluginInstance:set_data(data)

shared lib/plugin_instance.lua:76

Merges the fields of a table into the plugin object.

Parameters

  • data Map fields to merge

PluginInstance:set_description(desc)

shared lib/plugin_instance.lua:70

Sets the description of the plugin.

Parameters

  • desc String new description; the current description is kept if this is nil

PluginInstance:set_global(alias)

shared lib/plugin_instance.lua:83

Makes the plugin available as a global variable, unless a global table with that name already exists. Throws an error if the name starts with a lowercase letter.

Parameters

  • alias String name of the global, in ConstantStyle

PluginInstance:set_name(name)

shared lib/plugin_instance.lua:58

Sets the name of the plugin.

Parameters

  • name String new name; the current name is kept if this is nil

Defined in