Year of the Dragon: Through May 28th, claim free Expansion Pack (excluding Vecna Unleashed) or a Greater Elixir of Discovery! Speak to Xatheral in the Hall of Heroes. edit

Thank you for your patience while we continue to upgrade DDOwiki to the latest MediaWiki LTS version. If you find any errors on the site, please visit the Discord chat server and let us know.

Game mechanicsNewbie guideIn developmentDDO StoreSocial Media


ChallengesClassesCollectablesCraftingEnhancementsEpic DestiniesFavorFeats

GlossaryItemsMapsMonstersPlacesQuestsRacesReincarnationSkillsSpells


Please create an account or log in to remove ads, build a reputation, and unlock more editing privileges and then visit DDO wiki's IRC Chat/Discord if you need any help!

Template:Add

From DDO wiki
Jump to navigation Jump to search

USAGE[edit]

{{ Add | prefix= | template= | suppresserrors= | ... }}

This template adds numbers provided in its parameters.

Restrictions: |prefix= must not be a prefix of the word "prefix", "template" or "suppresserrors". (an empty prefix is a prefix of all. Prefixes "p", "t" and "s" are also out).

EXAMPLES[edit]

  • Pass parameters with a prefix given in the parameter {{{prefix|x}}} (needs to not be a prefix of "prefix"), and the template will add them.

Example: {{ Add | prefix=x | x1=1 | xqwerty=2 | x2=3 | x3= | other=100 }}

6

Empty parameters count as 0, parameters not starting with x are not added. If a parameter starting with x contains characters not recognised as numbers by {{#expr}}, then {{#expr}} will throw an error unless |suppresserrors= is not empty. If |suppresserrors= is not empty, then any invalid values will be treated as 0.

  • You can also provide a template that will take the values of the parameters and translate them into numbers. The template specified in {{{template}}} will be given one parameter and will be expected to produce a number.

Example: {{ Add | prefix=y | template=IO | y1=yes | y2=no | y3=false | y4=true }}

2
  • If no prefix is given, all parameters are added. This means that you can't provide a template to translate values into numbers.

Example: {{ Add | 1 | 2 | 3 | 4 | asdf=5 | x= }}

15
  • In addition to displaying the result, it also stores it in a variable called {{#var: sum<prefix>}}. This means that you can use the result of this template in more than one place.

Example: {{ Add | x1=1 | x2=1 | prefix=x }} {{ Add | y1=2 | y2=2 | prefix=y }} Results: {{#var: sumy}} and {{#var: sumx}}

2 4 Results: 4 and 2

CODE[edit]

0