Modèle:Sell expr
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 {{#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:
19
Proof: 5*( 1 *3 + 16 ) + 2 *7 = 5*( 19 ) + 14 = 95 + 14 = 19
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 if the second, fourth, etc. unnamed parameters are not valid
{{#expr:}}
syntax. - {{iteminfo}} can only handle items that are present in Bureau 1.4.4.9. 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 }} |
20 |
{{sell expr| True Excalibur|+|True Night's Edge }} |
20 |
{{sell expr|| (|Excalibur|+|Broken Hero Sword|) + (|Night's Edge|+|Broken Hero Sword|) }} |
2360 |
{{sell expr|| (12*|Hallowed Bar|+|Broken Hero Sword|) + ((|Blade of Grass|+|Volcano|+|Light's Bane|+|Muramasa|)+|Broken Hero Sword|) }} |
2290 |
{{sell expr| Wood|*5 }} |
0 |
{{sell expr| 12*|Terra Blade }} (1st parameter not an item name or ID, 2nd parameter an item name) |
(template error) |
{{sell expr|| 12*|Terra Blade }} (fixed the above) |
240 |
{{sell expr|||| | || ||| 6* ||||| Terra Blade |||||*2 ||}} (parameters can be empty) |
240 |
{{sell expr| Terra Blade|*|12 }} (typo: 12 is treated as an item ID here) |
10 |
{{sell expr| Tizona|+|Sharanga }} (items not available on Desktop 1.4.4.9) |
(template error) |
{{sell expr| Terra Blade|×12 }} (not valid syntax) |
0 |
{{sell expr| Terra Blade |raw=y}} |
200000 |