Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:ModuleAddSavedVariable

From RoR Wiki

UI Lua API · Module functions
Version: WAR 1.4.8

Adds a saved variable to a UI module at run time, as if it were listed in the module's .mod file.

ModuleAddSavedVariable(moduleName, variableName, flag)

Arguments

moduleName
string – The module's name, as in the name field of ModulesGetData.
variableName
string – Name of the Lua variable to save, for example "MyAddon.Settings".
flag
boolean – Selects which of the module's two saved-variable lists the name is added to. See Details.

Returns

Nothing.

Details

  • A module keeps two lists of saved variables. flag = false adds the name to the first list, true to the second. The name is refused if it is already in either list. The client also uses this routine for the <SavedVariable> names of the .mod file. Which list is saved where could not be confirmed.
  • The change is accepted only while the module is initialized or being initialized (from the moment its initialization starts). For a module that has not started initializing, the is not loaded error is logged. Its wording ("You may not modify the SavedVariables on a Module that is initialized") is the opposite of what the check does.
  • flag must be a real boolean. Passing nil or a number raises an Invalid Parameters error.
  • The function needs at least three arguments and only reads the last three.
  • The stock UI never calls ModuleAddSavedVariable; stock modules list their saved variables in their .mod files.

Errors

These are written to the UI log; the call returns normally.

  • Error in function call 'ModuleAddSavedVariable': %s is not a valid UiMod name.
  • Error in function call 'ModuleAddSavedVariable': %s is not loaded. You may not modify the SavedVariables on a Module that is initialized.
  • Error in function call 'ModuleAddSavedVariable': %s already has '%s' registered as a saved variable.

Example

A minimal example built from the signature above:

ModuleAddSavedVariable( "MyAddon", "MyAddon.Settings", false )

See also