LibUserScript

Script API

Scripts are essentially segments of Lua code that get run when a registered event fires. Scripts are provided with a state variable, access to settings (which can be manipulated using the blizzard addon panel), and a limited subset of the global environment. Using Lua comments, scripts can define properties (similar to the Outfitter script properties) to control events, display, and settings.


Scripts run every time a requested event fires.

Script Context

Currently there are two types of scripts. Scripts that are used to take pictures (events are ignored for these scripts) and those that are run when events happen.

Lua Scripts

Property definitions

Properties allow scripts to identify themselves and register for events and settings. Properties are defined using specially formated LUA comments.

-- $<property-name> <property-value>

Where <property-name> is one of the following:

EVENTS
Adds the space separated list of event names to the events to register for this script. Each EVENTS property is additive. See Event Names for a list of possible names.
DESCRIPTION
Sets the description for the script. This is a non-unique name used when listing the script.
SETTING
This defines a variable accessible to the script.
<property-value> may consist of one of two forms:
  • <setting-name> = <setting-type>
    Declares a setting with the given name and specified type. The label for the setting will be the setting itself. The default value will be a value appropriate for the given type.
  • <setting-name> = { ... }

Variables

Scripts may use the self variable to store transient information or the setting variable to access declared settings.

Attempting to declare a global variable will result in an error.

Environment

To limit the extent to which scripts can cause trouble, only those functions which can query state are provided or carry out needed actions are provided.

See Script API/Environment for a list of default global variables.


You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
29 Nov 2008

Author