Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:Variables
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local Class = require('Module:Class') local Variables = {} ---Stores a wiki-variable and returns the empty string ---@param name string Key of the wiki-variable ---@param value string Value of the wiki-variable ---@return string #always the empty string function Variables.varDefine(name, value) return mw.ext.VariablesLua.vardefine(name, value) end ---Stores a wiki-variable and returns the stored value ---@param name string Key of the wiki-variable ---@param value string Value of the wiki-variable ---@return string function Variables.varDefineEcho(name, value) return mw.ext.VariablesLua.vardefineecho(name, value) end ---Gets the stored value of a wiki-variable ---@generic T ---@param name string Key of the wiki-variable ---@param default T fallback value if wiki-variable is not defined ---@return string|T ---@overload fun(name: string):string? function Variables.varDefault(name, default) local val = mw.ext.VariablesLua.var(name) return (val ~= '' and val ~= nil) and val or default end --- ---@param ... string wiki-variable keys ---@return string function Variables.varDefaultMulti(...) --pack varargs local varargs = { n = select('#', ...), ... } for i = 1, varargs.n do local val = Variables.varDefault(varargs[i]) if val then return val end end -- If even the last var didn't bring anything return the last argument return varargs[varargs.n] end return Class.export(Variables, {removeBlanks = false})
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Variables/doc
(
edit
)
No categories
Edit