Extension:VariablesLua

Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:MIT licensed extensions
MediaWiki extensions manual
VariablesLua
Release status: stableCategory:Stable extensions
Implementation Parser extension Category:Parser extensions
Description Provides support for the Variables extension in Lua modules by the Scribunto extension
Author(s) Alex Winkler
Latest version 1.6.0 (2024-07-24)
MediaWiki 1.35+Category:Extensions with manual MediaWiki version
License MIT License
Download Category:Extensions in GitHub version control
Category:All extensions

The VariablesLua extension provides support for the Variables extension in Lua modules by the Scribunto extension.

Bugs and Feature Requests
Issues at GitHub

Usage

Manual: Liquipedia Help

The extension can be loaded in Lua modules by the Scribunto extension like this:

VariablesLua = mw.ext.VariablesLua

Functions

Functions are based on the ones provided by the Variables extension, adding some more utility.

VariablesLua.vardefine

VariablesLua.vardefine( name, value )

Stores the given value under the given name. An empty string is stored if the value is nil.

VariablesLua.vardefineecho

VariablesLua.vardefineecho( name, value )

Identical to VariablesLua.vardefine, but returns the value after storing it.

VariablesLua.var

VariablesLua.var( name, default )

Retrieve a variable stored under the given name.

VariablesLua.varexists

VariablesLua.varexists( name )

Check if a variable exists. Returns a boolean value.

VariablesLua.var_final

VariablesLua.var_final( name, default )

Returns the last value stored (i.e. the last VariablesLua.vardefine or #vardefine in the code). The value can only be returned and not used in the Lua code.

Installation

Version history

1.0.0
  • Initial release.
1.1.0
1.2.0
  • Added argument type checking.
1.2.1
  • Bug fixes.
1.3.0
  • Added mw.ext.VariablesLua.var_table().
1.4.0
  • Removed mw.ext.VariablesLua.var_table() due to changes in Extension:Variables.
1.4.1
  • Some minor updates, nothing security-relevant, can potentially avoid weird cases.
1.4.2
  • Renamed some functions and classes to align with the MediaWiki style guide.
1.5.0
  • Restored the boolean return value of mw.ext.VariablesLua.varexists().
1.6.0
  • Compatibility fixes for versions of Extension:Variables >= 2.6.0.

See also

Category:Scribunto extensions
Category:All extensions Category:Extensions in GitHub version control Category:Extensions included in Fandom Category:Extensions included in Miraheze Category:Extensions included in Telepedia Category:Extensions included in WikiForge Category:Extensions included in wiki.gg Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:MIT licensed extensions Category:Parser extensions Category:ScribuntoExternalLibraries extensions Category:Scribunto extensions Category:Stable extensions