Module:LuaVar: Difference between revisions

From IdleOn MMO Wiki
imported>Kiokurashi
No edit summary
imported>Kiokurashi
No edit summary
Line 11: Line 11:
local name = frame.args.name
local name = frame.args.name
local value = frame.args.value
local value = frame.args.value
VariablesLua.vardefineecho( name, value )
local data = VariablesLua.vardefineecho( name, value )
return data
end
end


return LuaVar
return LuaVar

Revision as of 02:39, 26 August 2021

Basics - Capitalization of LuaVar and the function (example varDefine) is required.:

To define a variable without returning the value:

{{#invoke:LuaVar|varDefine
|name= Variable Name
|value= Value
}}


To define a variable and return the value:

{{#invoke:LuaVar|varDefineEcho
|name= Variable Name
|value= Value
}}


To retrieve the value of a variable. Will inform if the variable is not defined.

{{#invoke:LuaVar|var
|name= Variable Name
}}

local LuaVar = {}
VariablesLua = mw.ext.VariablesLua

function LuaVar.varDefine(frame)
	local name = frame.args.name
	local value = frame.args.value
	VariablesLua.vardefine( name, value )
end

function LuaVar.varDefineEcho(frame)
	local name = frame.args.name
	local value = frame.args.value
	local data = VariablesLua.vardefineecho( name, value )
	
	return data
end

return LuaVar