Help:VariablesLua

From Liquipedia Commons Wiki

The VariablesLua extension is a direct interface to Extension:Variables. It supports all the functions that are supported by the main extension. This allows Scribunto Lua modules to exchange variables between each other and MediaWiki templates using the Extension:Variables parser functions.

Example[edit]

local p = {} -- p stands for package

function p.get(frame)
	local data = mw.ext.VariablesLua.var('variablename')
	-- data now holds the value of the variable "variablename"
	return data
end

function p.set(frame)
	mw.ext.VariablesLua.vardefine('variablename', 'variablevalue')
	-- The variable "variablename" now holds the value "variablevalue"
end

function p.setecho(frame)
	local data = mw.ext.VariablesLua.vardefineecho('variablename', 'variablevalue')
	-- The variable "variablename" now holds the value "variablevalue"
	-- data now has the value "variablevalue"
	return data
end

return p