From Brotato Wiki

(INITIAL \o/)
 
(add some notes explaining use for character unlocks wi. Iconbox)
 
Line 34: Line 34:
<code><nowiki>{{GetRarity|UNKNOWN}}</nowiki></code> = {{GetRarity|UNKNOWN}}
<code><nowiki>{{GetRarity|UNKNOWN}}</nowiki></code> = {{GetRarity|UNKNOWN}}


=== With [[Template:Iconbox|Iconbox]] ===
=== With Iconbox ===


<code><nowiki>{{Iconbox|Acid|rarity={{GetRarity|Acid}}}}</nowiki></code>
This function template is used by the <code>auto</code> option for [[Template:Iconbox]].


{{Iconbox|Acid|rarity={{GetRarity|Acid}}}}
<code><nowiki>{{Iconbox|Potato|rarity=auto}}</nowiki></code><br>
<code><nowiki>{{Iconbox|Hammer|rarity=auto}}</nowiki></code>
 
{{Iconbox|Potato|rarity=auto}} {{Iconbox|Hammer|rarity=auto}}
 
== Notes ==
 
This function template is most beneficial when showing a character's unlock, if you don't already know if their unlock is a [[Weapons|Weapon]] or an [[Items|Item]].
 
Ie. the <code>auto</code> option for [[Template:Iconbox|Iconbox]] is a shortcut to writing either:
 
<code><nowiki>{{Iconbox|Potato|rarity={{GetRarity|Potato}}}}</nowiki></code><br>
<code><nowiki>{{Iconbox|Hammer|rarity={{GetRarity|Hammer}}}}</nowiki></code>
 
{{Iconbox|Potato|rarity={{GetRarity|Potato}}}} {{Iconbox|Hammer|rarity={{GetRarity|Hammer}}}}
 
Or:
 
<code><nowiki>{{Iconbox|Potato|rarity={{Item_Data|Potato|rarity}}}}</nowiki></code><br>
<code><nowiki>{{Iconbox|Hammer|rarity={{Weapon_Data|Hammer|rarity}}}}</nowiki></code>
 
{{Iconbox|Potato|rarity={{Item_Data|Potato|rarity}}}} {{Iconbox|Hammer|rarity={{Weapon_Data|Hammer|rarity}}}}
 
It's especially helpful in templates related to [[Characters|Character]] unlocks. As shown above, there are already <code>rarity</code> options for [[Template:Item_Data|Item_Data]] and [[Template:Weapon_Data|Weapon_Data]], but this function saves you using a <code>switch</code> statement in your templates to choose whether to use  [[Template:Item_Data|Item_Data]] or [[Template:Weapon_Data|Weapon_Data]].


</noinclude>
</noinclude>

Latest revision as of 23:21, 9 November 2022


Gets the rarity for the provided name. Works with Items or Weapons (via GetType)

IMPORTANT: GetType (and therefore this helper too) relies on the #default for each entry always being "-" (in Item_Data, Weapon_Data, and Character_Data)

Examples

Items

{{GetRarity|Bat}} = 1

{{GetRarity|Acid}} = 2

{{GetRarity|Candle}} = 3

{{GetRarity|Cape}} = 4

Weapons

{{GetRarity|Chopper}} = 1

{{GetRarity|Hammer}} = 2

{{GetRarity|Minigun}} = 3

Unknown (0)

{{GetRarity|UNKNOWN}} = 0

With Iconbox

This function template is used by the auto option for Template:Iconbox.

{{Iconbox|Potato|rarity=auto}}
{{Iconbox|Hammer|rarity=auto}}

Notes

This function template is most beneficial when showing a character's unlock, if you don't already know if their unlock is a Weapon or an Item.

Ie. the auto option for Iconbox is a shortcut to writing either:

{{Iconbox|Potato|rarity={{GetRarity|Potato}}}}
{{Iconbox|Hammer|rarity={{GetRarity|Hammer}}}}

Or:

{{Iconbox|Potato|rarity={{Item_Data|Potato|rarity}}}}
{{Iconbox|Hammer|rarity={{Weapon_Data|Hammer|rarity}}}}

It's especially helpful in templates related to Character unlocks. As shown above, there are already rarity options for Item_Data and Weapon_Data, but this function saves you using a switch statement in your templates to choose whether to use Item_Data or Weapon_Data.