RestrictedEnvironment

Restricted environment refers to the environment in which restricted addon code (SecureHandler snippets) is executed. A limited subset of the WoW API is available within the environment.

Available API

 * ("conditionalString") : parses a macro conditional.
 * : returns current shape shift form.
 * : returns 1 if the player is stealthed
 * ("unit") : returns 1 if the unit exists.
 * ("unit") : returns 1 if the unit is dead.
 * ("unit") : returns 1 if the unit is a ghost.
 * ("unit") : returns 1 if the unit is a player or a pet in your party.
 * ("unit") : returns 1 if the unit is a player or a pet in your raid.
 * ,, : return 1 if the relevant key is held down.
 * ,, : return 1 if the relevant key is held down.
 * ,, : return 1 if the relevant key is held down.
 * : returns 1 if any alt, control or shift key is held down.
 * ("modifierType") : returns 1 if the associated modifier is held down.
 * : returns the mouse button responsible for the hardware click.
 * : returns the current action bar page.
 * : returns the current action bar "bonus" offset (stance-specific bars).
 * : returns 1 if the player is mounted.
 * : returns 1 if the player is swimming.
 * : returns 1 if the player is flying.
 * : returns 1 if the player is in a flyable area (Northrend, Outland).
 * : returns 1 if the player is indoors.
 * : returns 1 if the player is outdoors.
 * ("key") : returns the action bound to a key.
 * (slot) : returns 1 if an action is placed in the specified action bar slot.
 * (slot[, bookType] or "spellName") : returns 1 if the spell can be cast on hostile targets.
 * (slot[, bookType] or "spellName") : returns 1 if the item can be used on hostile targets.
 * (slot[, bookType] or "spellName") : returns 1 if the spell can be cast on friendly targets.
 * (slot[, bookType] or "spellName") : returns 1 if the item can be used on friendly targets.
 * ("unit") : returns 1 if the player can attack the specified unit.
 * ("unit") : returns 1 if the player can assist the specified unit.
 * : returns 1 if the player is channeling a spell.
 * : returns pet creature family and pet name.
 * : returns 1 if the player or his pet is in combat.
 * : returns "party" or "raid" if the player is in one of those group types.
 * ("unit") : returns 1 if the unit is in a vehicle that provides special UI.
 * (frame, state, conditional) : registers a SecureStateDriver for a specific frame.
 * (slot) : returns limited information about an action in a specific action slot.

Restricted tables
Only restricted tables are accessible within the restricted environment -- essentially, the real table instances are kept local to prevent unrestricted access to variables within the restricted environment. Most table functions within the restricted environment have been replaced by restricted table-aware versions, with the exception of the function (use the restricted table-aware  instead of table lookup functionality is desired).

The following table-related functions are usable inside the restricted environment:

Note that as the restricted environment doesn't contain proper function references, table.sort's second argument (comparison function) may not be used from within the restricted environment.

Other functions
The math and string standard library tables are provided in their entirety. The following table lists additional global functions that are also available in the restricted environment

Frame handle methods
Real frame userdata values may not exists within the restricted environment; instead, it the restricted environment may contain frame references (introduced via the :SetFrameRef("name", frame) method). A limited subset of the widget API can be invoked upon those references; only methods marked with a star may be called on references to non-protected frames.

Control methods
Additional methods are available as part of the control table; allowing functionality somewhat resembling proper functions within the protected environment.
 * control&#58;CallMethod("methodName", ...) : insecurely calls methodName method of the restricted environment's owner.
 * control&#58;Run("body", ...) : executes Lua code in body with the provided arguments; self is the handle of the environment's owner.
 * control&#58;RunFor(handle, "body", ...) : executes Lua code in body with the provided arguments; self is the argument value.
 * control&#58;RunAttribute("snippetAttr", ...) : executes the method contained in the snippetAttr attribute of the restricted environment owner with self, ... as arguments.
 * control&#58;ChildUpdate("snippetid", message) : executes the contents of "_childupdate-snippetid" (or, if that attribute is nil/false, "_childupdate"), on all protected children (and children of children) of the restricted environment owner with (self, scriptid, message) arguments.