Class PLUGIN

Plugin Metatable The PLUGIN metatable ascribes some basic functionality to assist in writing plugins faster.

Class Overview

Core Methods

PLUGIN:New(name[, author]) Create a new plugin.
PLUGIN:CallAsHook(name, ...) Call the hooks of this plugin.
PLUGIN:Call(name, ...) Call the hooks of this plugin, ignoring any output.
PLUGIN:Hook(name, func) Adds a hook function to the plugin.
PLUGIN:AddHook(name, func) Adds a hook function to the plugin, and also registers the hook with hook.Add
PLUGIN:Enable() Enable the plugin.
PLUGIN:Disable() Disable the plugin.
PLUGIN:Enabled() Get if the plugin is enabled.
PLUGIN:IsValid() Checks if the plugin is valid (currently checks enabled status)
PLUGIN:Register([name=self.name]) Registers the plugin.

Data Methods

PLUGIN:CreateFolder(fullPath) Create a folder, along with any intermedate folders.
PLUGIN:DataFolder() Gets the data folder for this plugin.
PLUGIN:CreateDataFolder() Creates this plugin's data folder.
PLUGIN:DataFile(name) Gets the path to a data file for this plugin.
PLUGIN:MapFolder() Gets the data folder for this plugin on the current map.
PLUGIN:CreateMapFolder() Creates this plugin's data folder for the current map.
PLUGIN:MapFile(name) Gets the path to a map file for this plugin.
PLUGIN:OpenDataFile(name[, mode=r]) Gets the file class for the given file.
PLUGIN:OpenMapFile(name[, mode=r]) Gets the file class for the given file.

Abstracted Data Methods

PLUGIN:ReadDataFile(name) Reads a given data file.
PLUGIN:WriteDataFile(name, contents) Writes a given data file.
PLUGIN:ReadMapFile(name) Reads a given data file.
PLUGIN:WriteMapFile(name, contents) Writes a given data file.

Core Methods

PLUGIN:New(name[, author])
Create a new plugin.

Parameters:

  • name string Plugin Name.
  • author string Authors. (optional)

Returns:

    PLUGIN
PLUGIN:CallAsHook(name, ...)
Call the hooks of this plugin.

Parameters:

  • name string Name of the hook to call.
  • ... vararg Data to pass to the hook function.

Returns:

    vararg Returns from the called functions.
PLUGIN:Call(name, ...)
Call the hooks of this plugin, ignoring any output.

Parameters:

  • name string Name of the hook
  • ... vararg Data to pass to the hook function.

Returns:

    vararg Returns from the called functions.

See also:

PLUGIN:Hook(name, func)
Adds a hook function to the plugin.

Parameters:

  • name string Hook name.
  • func func Function to add.

Returns:

    PLUGIN
PLUGIN:AddHook(name, func)
Adds a hook function to the plugin, and also registers the hook with hook.Add

Parameters:

  • name string Hook name.
  • func func Function to add.

Returns:

    PLUGIN
PLUGIN:Enable()
Enable the plugin.

Returns:

    PLUGIN
PLUGIN:Disable()
Disable the plugin.

Returns:

    PLUGIN
PLUGIN:Enabled()
Get if the plugin is enabled.

Returns:

    bool
PLUGIN:IsValid()
Checks if the plugin is valid (currently checks enabled status)

Returns:

    bool

See also:

PLUGIN:Register([name=self.name])
Registers the plugin.

Parameters:

  • name string Name to register the plugin with, if not already defined. (default self.name)

Data Methods

PLUGIN:CreateFolder(fullPath)
Create a folder, along with any intermedate folders.

Parameters:

  • fullPath string Folder path.

Returns:

    PLUGIN
PLUGIN:DataFolder()
Gets the data folder for this plugin.

Returns:

    string
PLUGIN:CreateDataFolder()
Creates this plugin's data folder.

Returns:

    PLUGIN
PLUGIN:DataFile(name)
Gets the path to a data file for this plugin.

Parameters:

Returns:

    string Full path.
PLUGIN:MapFolder()
Gets the data folder for this plugin on the current map.

Returns:

    string
PLUGIN:CreateMapFolder()
Creates this plugin's data folder for the current map.

Returns:

    PLUGIN
PLUGIN:MapFile(name)
Gets the path to a map file for this plugin.

Parameters:

Returns:

    string Full path.
PLUGIN:OpenDataFile(name[, mode=r])
Gets the file class for the given file.

Parameters:

Returns:

    file_class

See also:

PLUGIN:OpenMapFile(name[, mode=r])
Gets the file class for the given file.

Parameters:

Returns:

    file_class

See also:

Abstracted Data Methods

PLUGIN:ReadDataFile(name)
Reads a given data file.

Parameters:

Returns:

    string File contents.
PLUGIN:WriteDataFile(name, contents)
Writes a given data file.

Parameters:

Returns:

    PLUGIN
PLUGIN:ReadMapFile(name)
Reads a given data file.

Parameters:

Returns:

    string File contents.
PLUGIN:WriteMapFile(name, contents)
Writes a given data file.

Parameters:

Returns:

    PLUGIN