Difference between revisions of "Template:NPCLootTable/row"

From Stoneshard wiki
Jump to navigation Jump to search
m (Test)
(Fix & clean base logic. The category icons are how planned. Needs images fix for the items in each category.)
Line 1: Line 1:
<includeonly><!--  {{NPCLootTable/row|Trade|Type}} ---
<includeonly><!--  {{NPCLootTable/row|Bert|Sells|Weapons}} ---
     --- Define variables, goal is to only load each property from the Data page once. ---
     --- Define variables, goal is to only load each property from the Data page once. ---
     -->{{#vardefine:Datastring|{{:NPCLoot data|{{{1}}}}}}}<!--
     -->{{#vardefine:Datastring|{{:NPCLoot data|{{{1}}}}}}}<!--
     -->{{#vardefine:Exists|{{#ifeq: {{:Friendly data|{{{1}}}|Occupation}}|NPC {{{1}}} does not exist in [[Friendly data]].||{{:Friendly data|{{{1}}}|Occupation}}}}}}<!--
     --- Maybe implement later with Friendly data --
    --- Fetch Buys and Sells data --
     -->{{#vardefine:Name|{{{1}}}}} <!-- define npcname for tests
     -->{{#vardefine:Buys|{{:Datastring|{{#var:{{PAGENAME}}}}|Buys}}}}<!--
     -->{{#vardefine:Action|{{{2}}}}}<!-- Defines Action = second parameter
    -->{{#vardefine:Sells|{{:Datastring|{{#var:{{PAGENAME}}}}|Sells}}}}<!--
     -->{{#vardefine:Category|{{{3}}}}}<!-- Defines Category = third parameter
    --- Define variables for the type and item from the NPC ---
     -->{{#vardefine:CategoryData|{{#var:Datastring|{{{3}}}}}}}<!-- "| Weapons"
     -->{{#vardefine:NPC|{{{PAGENAME}}}}} <!-- NPC name ---
     -->{{#vardefine:Items|{{#explode:{{#var:CategoryData}}|;}}}}<!--"Training Crossbow"
     -->{{#vardefine:Trade|{{{1}}}}} <!-- Buys or Sells ---
     --- First column: Category -->
     -->{{#vardefine:Category|{{{2}}}}} <!-- Category of Items ---
    |-
    --- Load translations that are used multiple times into variables. ---
     | <!--{{#ifexist:{{#var:Action}}|[[File:Purse.png|42px]]|No Action provided for image}}
    -->{{#vardefine:TranslateCategory|{{Translate|{{{1}}}|Properties}}}}<!--
     -->'''{{{3}}}'''<br>{{#if:{{#var:Category}}|[[File:{{#var:Category}}_icon.png|42px]]}}<!--
    --- Load translated description or fallback to base description ---
     --- Second column: Items -->
     --> {{#vardefine:ItemDescription|{{#ifexist:Template:{{uc:{{SUBPAGENAME}}}}_Properties|{{:Template:{{uc:{{SUBPAGENAME}}}}_Properties|{{{1}}}}}|{{#var:ItemDescription}}}}}} <!--
     | <!--{{#if:{{#var:Items}}|{{:CategoryData|{{#var:Items}}}}|No Items Found}}
     --- Define "Link" var, with a subpage verification. If subpagename = pagename, we are not on a subpage, therefore URL becomes "item name". If we are on a subpage, URL becomes "item name/subgpagename". Used for other languages. ---
     --><span class="stoneshard sortable" style="display: flex; text-align: center; justify-content: center;"><!-- Flex container ---
     -->{{#vardefine:Link|{{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}}}<!--
        -->{{#if:{{#explode:{{#var:Items}}|;|1}}|{{#explode:{{#var:Items}}|;|1}} [[File:{{#explode:{{#var:Items}}|;|1}}_icon.png|37px|link=]]|No image found }}<!--
    -->
        -->{{#if:{{#explode:{{#var:Items}}|;|2}}|{{#explode:{{#var:Category}}|;|2}} [[File:{{#explode:{{#var:Category}}|;|2}}.png|45px|link=]]|B }}<!--
     |- <!-- Second column [Name & Icon inside row] -->
        -->{{#if:{{#explode:{{#var:Items}}|;|3}}|{{#explode:{{#var:Category}}|;|3}} [[File:{{#explode:{{#var:Category}}|;|3}}.png|45px|link=]]|C }}<!--
    | '''[[{{#var:Link}}|{{#if:{{#var:TranslateName}}|{{#var:TranslateName}}|{{{1}}}}}]]'''<!--
        -->{{#if:{{#explode:{{#var:Items}}|;|4}}|{{#explode:{{#var:Category}}|;|4}} [[File:{{#explode:{{#var:Category}}|;|4}}.png|45px|link=]]|D }}<!--
    --><br>[[File:Armor_icon.png|42px|link=|]]
        -->{{#if:{{#explode:{{#var:Items}}|;|5}}|{{#explode:{{#var:Category}}|;|5}} [[File:{{#explode:{{#var:Category}}|;|5}}.png|45px|link=]]|E }}<!--
    | {{#if:{{#var:Exists}}|[[File:{{#if:{{#var:Image}}|{{#var:Image}}|{{{1}}}.png}}|37px|link={{#if:{{#var:Name}}|{{#if:{{#pos:{{lc:{{#var:Name}}}}|random}}||{{Translate|{{#var:Name}}|NPCNames}}}}|{{Translate|{{{1}}}|NPCNames}}}}]]<!--
     --></span><!--
     --- Extra images for NPC entries like generic guards or peasants. Many face images with no link. ---
     -->{{#if:{{#var:Image2}}|[[File:{{#var:Image2}}|37px|link=]]}}<!--
     --><br>{{#if:{{#var:Name}}|{{#if:{{#pos:{{lc:{{#var:Name}}}}|random}}|{{Translate|{{#var:Name}}|NPCNames}}|[[{{Translate|{{#var:Name}}|NPCNames}}]]}}|[[{{Translate|{{{1}}}|NPCNames}}]]}}}}<!--
    -->{{#if:{{#var:Exists}}|{{#if:{{:NPCLoot data|{{{1}}}|Quest}}|'''✓'''}}}}{{#if:{{{2|}}}|<sup>{{{2|}}}</sup>}}<!--
    <!-- Display items in the specified category -->
    {{#explode:{{#var:CategoryData}}|;|1}} [[File:{{#explode:{{#var:CategoryData}}|;|1}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|1}}]]<!--
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|2}}|{{#explode:{{#var:CategoryData}}|;|2}} [[File:{{#explode:{{#var:CategoryData}}|;|2}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|2}}]]}}<!--
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|3}}|{{#explode:{{#var:CategoryData}}|;|3}} [[File:{{#explode:{{#var:CategoryData}}|;|3}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|3}}]]}}<!--
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|4}}|{{#explode:{{#var:CategoryData}}|;|4}} [[File:{{#explode:{{#var:CategoryData}}|;|4}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|4}}]]}}<!--
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|5}}|{{#explode:{{#var:CategoryData}}|;|5}} [[File:{{#explode:{{#var:CategoryData}}|;|5}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|5}}]]}}<!--
     -->{{#if:{{#explode:{{#var:CategoryData}}|;|6}}|{{#explode:{{#var:CategoryData}}|;|6}} [[File:{{#explode:{{#var:CategoryData}}|;|6}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|6}}]]}}<!--
--></includeonly><noinclude>{{doc|Template:NPCLootTable/row}}[[Category:Templates]]</noinclude>
--></includeonly><noinclude>{{doc|Template:NPCLootTable/row}}[[Category:Templates]]</noinclude>

Revision as of 22:08, 26 January 2025

Template-info.png Documentation

This article is a stub. You can help Stoneshard wiki by expanding it.

This Template is used to display every category & type of items a NPC trades.

Syntax

{{NPCTable/head}}

Usage

The header is always followed by the {{NPCLootTable/row}}, according to the necessary amount of NPCs to be display.

{{NPCLootTable/head|Bert}}
{{NPCLootTable/row}}
|}

Any NPC Loot information added in NPCLoot data, can be used with the '/row' template.

Examples

A) With a NPC {{NPCLootTable/head|Bert}}:

Category Types

B) With {{NPCLootTable/head|Bert}} & {{NPCLootTable/row|NPC*}}:

Trades

Bert as example

Buys

  • With "head|Bert|Buys", "Buys" & "end"
Bert Buys
Category Types
{{{3}}}
[[File:{{{3}}}_icon.png|42px]]
No image foundBCDE
{{{2}}})
  • With "head" & "Buys"
Category Types
{{{3}}}
[[File:{{{3}}}_icon.png|42px]]
No image foundBCDE

Sells

  • With "head", "Sells" & "end"
Category Types
Weapons
Weapons icon.png
No image foundBCDE
{{{2}}})
  • With "head|Bert|Sells" & "SellsX3"
Bert Sells
Category Types
Weapons
Weapons icon.png
No image foundBCDE
Armor
Armor icon.png
No image foundBCDE
Tools
Tools icon.png
No image foundBCDE
  • With "head" & "SellsX2"
Category Types
Weapons
Weapons icon.png
No image foundBCDE
Tools
Tools icon.png
No image foundBCDE