File Globals.lua

Functions

Globals:getValue (name) Get global variable value, without throwing error if global policy is strict and variable is undefined.
Globals:initVar (name, value, overwriteOk) Declare a global variable with an initial (optional) value.
Globals:isDeclared (name) Determine if variable is declared globally, even if value is nil (applies to strict policy only).
Globals:new (t) Constructor for new global environment manager.
Globals:setStrict (strict, t) Set strict or lax global policy.
Globals:setValue (name, value) Glorified rawset.


Functions

Globals:getValue (name)
Get global variable value, without throwing error if global policy is strict and variable is undefined.

Parameters:

  • name: (string, required) any variable name.

Usage:

    keeps from throwing an error when global policy is strict. 

Return value:

    value iff in global table and value is not nil, else nil.
Globals:initVar (name, value, overwriteOk)
Declare a global variable with an initial (optional) value.

Parameters:

  • name: (string, required) any variable name.
  • value: (any lua value, required) variable's value.
    even if value is nil, this function still serves as a global variable definition
    such that subsequent access will not throw an error, even if policy is strict.
  • overwriteOk:

Usage:

    *** It is not recommended to use this function except during initialization. its considered "best practice" when using the framework to define all global variables in init.lua. 
Globals:isDeclared (name)
Determine if variable is declared globally, even if value is nil (applies to strict policy only).

Parameters:

  • name:
Globals:new (t)
Constructor for new global environment manager.

Parameters:

  • t: initialization table, including:
    strict (boolean, default true) - global access policy.
Globals:setStrict (strict, t)
Set strict or lax global policy.

Parameters:

  • strict: (boolean, default false) true => make strict (undeclared var access generates error), false => make lax (undeclared access allowed).
    setting strict to true will clear out all previous explicit declarations.
  • t: (table, required) table to make strict access policy. In plugin's Init.lua, this is usually _G.

Usage:

  • although lax sounds better, strict is better (Lr2 is strict by default, Lr3 is lax by default).
  • *** Note: this is not an object method. 
Globals:setValue (name, value)
Glorified rawset.

Parameters:

  • name:
  • value:

Valid XHTML 1.0!