Year of the Dragon: Through April 23rd, claim the adventure pack Slice of Life for free! Speak to Xatheral in the Hall of Heroes.

Game mechanicsNewbie guideIn developmentDDO StoreSocial Media


ChallengesClassesCollectablesCraftingEnhancementsEpic DestiniesFavorFeats

GlossaryItemsMapsMonstersPlacesQuestsRacesReincarnationSkillsSpells


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

Template:Distinct values

From DDO wiki
Jump to navigation Jump to search

Usage[edit]

This template collects only the distinct values passed to it through the parameters and then passes those values to another template of your choice.

  • prefix parameter marks a prefix that the selected parameters should have. Default prefix is x. For example, if prefix is x, then all the values passed to this template should have parameter names starting with "x". | x1=foo | x2=bar | xasdf=1. This prefix should not be a prefix of the words "prefix", "temp_prefix", "template". Note that an empty prefix is a prefix of all.
  • temp_prefix parameter is a temporary prefix used for internal variables that this template uses to collect the distinct values. This prefix should be something unique and hard to find as a variable name elsewhere. Default prefix is temp
  • template parameter is the name of the template that you want the values propagated to. It is passed 3 parameters: {{{prefix}}} is the same as the prefix given above. {{{num}}} is the ascending number of the value encountered. This number starts from 1 and increments by 1 for every new value. {{{value}}} is the value found. This template will be called for every unique value found. The result of this template will be the result from all the calls to the specified template.

After completion, this template leaves behind many trash variables with prefixes "<temp_prefix>" and a variable {{#var: num<prefix>}} that holds the number of unique values encountered.

This template is useful when used in DPL statements. Passing the results from DPL to parameters of this template and then doing something with the unique values. An example of a template that can be used to do something with the values is Template:Generate variable.

Examples[edit]

<!-- Select distinct values and place them into variables -->
{{Distinct values
 | prefix = m
 | temp_prefix = an_unlikely_prefix
 | template = Generate variable
<!-- values -->
 | m1 = hello
 | m2 = world!
 | masd = 2
 | mmmmmm = hello
 | mmmm2 = 2
}}
<!-- Now to print the variables that Template:Generate variable created. -->
{{#loop: loop_index
 | 1
 | {{#var: numm}} <!-- This variable says how many values we have -->
 | Value {{#var: loop_index}}: {{#var: m{{#var: loop_index}} }}<br/> <!-- print the variables m1, m2, ... -->
}}

Value 1: hello
Value 2: world!
Value 3: 2

  • How to use this template in a DPL statement:
{{#dpl:
 | category = Patron factions
 | uses = Template:Patron
 | include = -
 | mode = userformat
 | listseparators = {{Distinct values {{!}} prefix=pf {{!}}template=Generate variable,{{!}}pf%NR%= %PAGE%,,}}
}}
{{#loop: loop_index
 | 1
 | {{#var: numpf}}
 | {{#var: pf{{#var: loop_index}} }}<br/>
}}

House Deneith
House Jorasco
House Kundarak
House Phiarlan
The Twelve
The Coin Lords
Agents of Argonnessen
The Free Agents
The Silver Flame
The Yugoloth
House Cannith
Purple Dragon Knights
The Harpers
The Gatekeepers
Keepers of the Feather
Sharn City Council
Morgrave University
The Summer Court

CODE[edit]