Template:Drop: Difference between revisions

From OpenSpell Wiki
Jump to navigationJump to search
Created page with "<noinclude> == Usage == Use inside a drop table. Automatically colours and labels the rarity based on the odds value. <pre> {| class="wikitable sortable" ! Item !! Amount !! Rarity !! Odds {{Drop|bones|1|always}} {{Drop|coins|20|0.15}} {{Drop|iron sword|1|0.02}} {{Drop|silver helm|1|0.005}} |} </pre> === Odds parameter === Either pass a number between 0 and 1, or one of these keywords: * <code>always</code> — guaranteed drop, no odds shown * Any decimal like <code>0...."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<noinclude>
<noinclude>
== Usage ==
== Usage ==
Use inside a drop table. Automatically colours and labels the rarity based on the odds value.
Use inside a drop table. Automatically colours, labels and formats odds.


<pre>
<pre>
Line 7: Line 7:
! Item !! Amount !! Rarity !! Odds
! Item !! Amount !! Rarity !! Odds
{{Drop|bones|1|always}}
{{Drop|bones|1|always}}
{{Drop|coins|20|0.15}}
{{Drop|coins|20|0.25}}
{{Drop|iron sword|1|0.02}}
{{Drop|iron sword|1|0.02}}
{{Drop|silver helm|1|0.005}}
{{Drop|silver helm|1|0.005}}
Line 13: Line 13:
</pre>
</pre>


=== Odds parameter ===
Odds is a decimal between 0 and 1, or the word <code>always</code>.
Either pass a number between 0 and 1, or one of these keywords:
* <code>always</code> — guaranteed drop, no odds shown
* Any decimal like <code>0.25</code>, <code>0.05</code>, <code>0.008</code>
 
The template picks the label and colour automatically:
{| class="wikitable"
! Range !! Label !! Colour
|-
| always || <span style="color:#2a7a2a;font-weight:600;">Always</span> || Green
|-
| ≥ 25% || <span style="color:#2a7a2a;font-weight:600;">Always</span> || Green
|-
| 10–25% || <span style="color:#555;">Common</span> || Grey
|-
| 5–10% || <span style="color:#c07020;">Uncommon</span> || Orange
|-
| 1–5% || <span style="color:#c03030;">Rare</span> || Red
|-
| < 1% || <span style="color:#900090;font-weight:600;">Very rare</span> || Purple
|}


[[Category:Drop templates]]
[[Category:Drop templates]]
Line 39: Line 19:
<includeonly>
<includeonly>
|-
|-
| [[{{{1}}}]] || {{{2|1}}} || {{Drop/colour|{{{3}}}}} || {{Drop/odds|{{{3}}}}}
| [[{{{1}}}]] || {{{2|1}}} || {{#ifeq:{{{3}}}|always|<span style="color:#2a7a2a;font-weight:600;">Always</span>|{{#ifexpr:{{{3}}}>=0.10|<span style="color:#555;">Common</span>|{{#ifexpr:{{{3}}}>=0.05|<span style="color:#c07020;">Uncommon</span>|{{#ifexpr:{{{3}}}>=0.01|<span style="color:#c03030;">Rare</span>|<span style="color:#900090;font-weight:600;">Very rare</span>}}}}}}}} || {{#ifeq:{{{3}}}|always|—|1/{{#expr:1/{{{3}}} round 0}}}}
</includeonly>
</includeonly>

Latest revision as of 14:00, 28 February 2026

Usage

[edit]

Use inside a drop table. Automatically colours, labels and formats odds.

{| class="wikitable sortable"
! Item !! Amount !! Rarity !! Odds
{{Drop|bones|1|always}}
{{Drop|coins|20|0.25}}
{{Drop|iron sword|1|0.02}}
{{Drop|silver helm|1|0.005}}
|}

Odds is a decimal between 0 and 1, or the word always.