틀:Sell expr/doc
This template can be used to handle elaborate expressions in conjunction with item sell values. The sell values are generated using {{iteminfo}}, hence they are dynamic and are adjusted accordingly should they be altered in a future Terraria update.
It aims at simplifying the convoluted syntax that is required for displaying sell value expressions: {{coin|{{#expr:{{iteminfo|Pixie Dust|value|raw=y}}/5*99+{{iteminfo|Crystal Shard|value|raw=y}}/5*33}}}}
can be shortened to {{sell expr|Pixie Dust|*99+|Crystal Shard|*33}}
using this template.
For handling buy prices instead of sell values, use {{buy expr}}. The syntax and usage is exactly the same.
Usage
{{ sell expr | <item name or ID 1> | <expression operators/constants/etc. 1> | ... | ... | <item name or ID n> | <expression operators/constants/etc. n> | raw = y/yes (optional) | round = <digit to round to> (optional) }}
- 1st, 3rd, 5th, 7th, ..., nth unnamed parameter
Name or ID of an item whose sell value is to be inserted at that part of the expression. Can be empty.
- 2nd, 4th, 6th, 8th, ..., (n+1)-th unnamed parameter
Operators, constants, etc. – valid {{#[[[:틀:Tl/parser function links]]##expr expr]:}}
syntax. Can be empty.
- raw
Suppress the {{coin}} wrapping and instead display the numerical value, e.g. for use in other expressions.
- round
Rounding functionality of {{coin}}, see Template:Coin for documentation and examples. Has no effect when using raw=y
.
Concept
Example: Multiply the sum of the sell values of 3 Pixie Dust and 1 Crystal Shard by 5 and add the sell value of 7 Souls of Light.
Think of writing the expression normally:
{{#expr: 5*( <Pixie Dust sell value>*3 + <Crystal Shard sell value> ) + <Soul of Light sell value>*7 }}
For this template, simply replace the <item name sell value>
parts with |<item name>|
:
{{sell expr| 5*( |Pixie Dust|*3 + |Crystal Shard| ) + |Soul of Light|*7 }}
Now check if the first unnamed parameter is still an item name or ID. If it is not, add an empty parameter to fix that:
{{sell expr| | 5*( |Pixie Dust|*3 + |Crystal Shard| ) + |Soul of Light|*7 }}
Result:
틀:Sell expr
Proof: 5*( 1 SC *3 + 16 SC ) + 2 SC *7 = 5*( 틀:Sell expr ) + 틀:Sell expr = 틀:Sell expr + 틀:Sell expr = 틀:Sell expr
Notes
- The template will display an error if the first, third, etc. unnamed parameters are not names or IDs of items. It will display 0 CC if the second, fourth, etc. unnamed parameters are not valid
{{#[[[:틀:Tl/parser function links]]##expr expr]:}}
syntax. - {{iteminfo}} can only handle items that are present in 틀:Desktop [[틀:V]]. Using items exclusive to non-Desktop platforms will cause a template error.
- The {{coin}} template (used for final formatting) does not handle negative values, so the final result must be above zero.
Examples
Code | Result |
---|---|
{{sell expr| Terra Blade }} |
틀:Sell expr |
{{sell expr| True Excalibur|+|True Night's Edge }} |
틀:Sell expr |
{{sell expr|| (|Excalibur|+|Broken Hero Sword|) + (|Night's Edge|+|Broken Hero Sword|) }} |
틀:Sell expr |
{{sell expr|| (12*|Hallowed Bar|+|Broken Hero Sword|) + ((|Blade of Grass|+|Fiery Greatsword|+|Light's Bane|+|Muramasa|)+|Broken Hero Sword|) }} |
틀:Sell expr |
{{sell expr| Wood|*5 }} |
틀:Sell expr |
{{sell expr| 12*|Terra Blade }} 틀:Note |
틀:Note |
{{sell expr|| 12*|Terra Blade }} 틀:Note |
틀:Sell expr |
{{sell expr||||틀:Spaces| ||틀:Spaces||| 6*틀:Spaces||||| Terra Blade |||||*2 ||}} 틀:Note |
틀:Sell expr |
{{sell expr| Terra Blade|*|12 }} 틀:Note |
틀:Sell expr |
{{sell expr| Tizona|+|Sharanga }} 틀:Note |
틀:Note |
{{sell expr| Terra Blade|×12 }} 틀:Note |
틀:Sell expr |
{{sell expr| Terra Blade |raw=y}} |
틀:Sell expr |
- Pages using DynamicPageList3 parser function
- Pages using DynamicPageList3 dplreplace parser function
- Pages using DynamicPageList3 dplvar parser function
- Template documentation