Home
Random
Recent changes
Special pages
Community portal
Preferences
About Sundering
Disclaimers
Sundering
Search
User menu
Talk
Contributions
Create account
Log in
Patches
|
Items
|
Quests
|
Creatures
|
Dungeons
|
NPCs
Attributes
|
Skills
|
Titles
|
XP Augmentation
|
Luminance Augmentation
|
Tailoring
Character Creation
β’
New Player Guide
β’
User Interface
β’
Glossary
Editing
How To Use Variables
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!
{{RightToC}} {{Related|Help:Contents|Wiki Templates}} This function allows you to define a variable on a page, use it later in that same page, change its value, possibly to a value given by an expression in terms of the old value, etc. It's much like a template, only very lightweight and scoped to only a single page, so you can use many variables on a page without polluting the wiki with huge numbers of templates. *This function requires the [http://www.mediawiki.org/wiki/Extension:VariablesExtension Variables] Extension be installed. == Assigning a value to a variable == === #vardefine === :<nowiki>{{#vardefine:</nowiki>''variablename''|''specifiedvalue''}} assigns the value ''specifiedvalue'' to the (already existing or hereby introduced) variable ''variablename''. === #vardefineecho === :<nowiki>{{#vardefineecho:</nowiki>''variablename''|''specifiedvalue''}} works exactly as <tt>#vardefine</tt>, but the affected value is printed. == Retrieving the value of a variable (#var) == The value of the variable ''variablename'' is produced by :<nowiki>{{#var:</nowiki>''variablename''}} If undefined, this produces the empty string; it does not give an error message. It's possible to define a value for the case that the variable is undefined or void: :<nowiki>{{#var:</nowiki>''variablename'' <nowiki>|</nowiki>''defaultvalue''<nowiki>}}</nowiki> This is equivalent to: :<nowiki>{{#if:</nowiki> <nowiki>{{#var</nowiki>:''variablename''}} |<nowiki>{{#var</nowiki>:''variablename''}} |''defaultvalue''}} but it's much shorter and better arranged. The value can be used in parser functions, etc. == #varexists == :<nowiki>{{#varexists:</nowiki>''variablename''}} returns ''1'' if the variable is already defined (also when the value is a void string). If the variable is not defined the return value is void. ==Examples== : ''Note that the ParserFunctions extension must also be installed to use #expr'' Compute 2*a + b: :<nowiki>{{#expr:2*{{#var:a}}+{{#var:b}}}}</nowiki> Add one to n: :<nowiki>{{#vardefine:n|{{#expr:{{#var:n}}+1}}}}</nowiki> [[Category:Help]]
Summary:
Please note that all contributions to Sundering 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
Sundering:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
If you're new to the wiki, please take a moment to review our
Naming Conventions
and
Page Templates
. Using proper article names and image formats/sizes keep the wiki clean and helps avoid duplicate entries. Thanks!
Templates used on this page:
Template:Related
(
edit
)
Template:RightToC
(
edit
)