Difference between revisions of "Template:Habitats"

From RimWorld Wiki
Jump to navigation Jump to search
(created template)
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>
+
<noinclude>{{Documentation}}</noinclude><includeonly>{{#vardefine: habitatString | {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Temperate Forest}}|[[temperate forest]]s,&#32;}}<!--
Returns a nicely-formatted list of all the biomes an animal can appear in.
+
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Temperate Swamp}}|[[temperate swamp]]s,&#32;}}<!--
 
+
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tropical Rainforest}}|[[tropical rainforest]]s,&#32;}}<!--
For example, if used on [[Megasloth]]: {{Habitats|Megasloth}}
+
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tropical Swamp}}|[[tropical swamp]]s,&#32;}}<!--
</noinclude><includeonly>{{#vardefine:total_habitats|{{#expr:{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Temperate Forest}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Temperate Swamp}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tropical Rainforest}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tropical Swamp}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Arid Shrubland}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Desert}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Extreme Desert}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Boreal Forest}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Cold Bog}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tundra}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Ice Sheet}}|1|0}} + {{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Sea Ice}}|1|0}}}}}}
+
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Arid Shrubland}}|[[arid shrubland]]s,&#32;}}<!--
{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Temperate Forest}}|temperate forests{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Temperate Swamp}}|temperate swamps{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tropical Rainforest}}|tropical rainforests{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tropical Swamp}}|tropical swamps{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Arid Shrubland}}|arid shrublands{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Desert}}|deserts{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Extreme Desert}}|extreme deserts{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Boreal Forest}}|boreal forests{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Cold Bog}}|cold bogs{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tundra}}|tundra{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Ice Sheet}}|ice sheets{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Sea Ice}}|sea ice{{#vardefine:total_habitats|{{#expr:{{#var:total_habitats}} - 1}}}}{{#ifexpr:{{#var:total_habitats}} > 1|, |{{#ifexpr:{{#var:total_habitats}} > 0|, and }}}}}}</includeonly>
+
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Desert}}|[[desert]]s,&#32;}}<!--
 +
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Extreme Desert}}|[[extreme desert]]s,&#32;}}<!--
 +
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Boreal Forest}}|[[boreal forest]]s,&#32;}}<!--
 +
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Cold Bog}}|[[cold bog]]s,&#32;}}<!--
 +
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Tundra}}|[[tundra]],&#32;}}<!--
 +
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Ice Sheet}}|[[ice sheet]]s,&#32;}}<!--
 +
-->{{#if:{{Q|{{{1|{{PAGENAME}}}}}|Lives In Sea Ice}}|[[sea ice]],&#32;}}}}<!--
 +
Extract the last term, if its the only term then print it, else replace the last term in the whole string with the last term with the and/or in front of it, then trim the extraneous comma and space off the final string
 +
-->{{#ifeq: {{#vardefineecho: lastTerm | {{#explode:{{#var: habitatString}}|,&#32;|-2}} }},&#32; | {{#var: habitatString}}|{{#var: lastTerm}}|{{#sub:{{#replace:{{#var: habitatString}}|{{#var: lastTerm}}|&#32;{{#if:{{{2|}}}|or|and}} {{#var: lastTerm}}}}||-6}} }}</includeonly>

Latest revision as of 11:09, 29 September 2022

Documentation icon Template documentation[view] [edit] [history] [purge]

Returns a nicely-formatted list of all the biomes an animal or plant can appear in as defined by the "Lives in" properties.

Parameters[edit]

All parameters are optional.

The first parameter defines the animal or plant of which to display the native biomes. If no value is set, it defaults to the current page.

The second, if present, changes the word between the last two habitats from "and" to "or". Any text will work, but "or" is suggested for clarity's sake.

Examples[edit]

{{Habitats}}

If used on Timber wolf, would result in: temperate forests, temperate swamps, boreal forests, cold bogs, and tundra.

{{Habitats|Bamboo tree}}

If used on any page, would result in: tropical rainforests.

{{Habitats|Cobra|or}}

If used on any page, would result in: tropical rainforests, or tropical swamps.

Wild healroot can spawn in a number of biomes including {{Habitats|Wild healroot}}.

If used on any page, would result in: Wild healroot can spawn in a number of biomes including temperate forests, temperate swamps, boreal forests, cold bogs, and tundra.