Difference between revisions of "Template:NPCLootTable/row"

From Stoneshard wiki
Jump to navigation Jump to search
m (Fix base idea. Clear code.)
(Add translation logic & test for template use.)
Line 1: Line 1:
<includeonly><!--  
<includeonly><!--   {{NPCLootTable/row|Trade|Type}} ---
     --- 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}}}}}}<!--
     -->{{#vardefine:Exists|{{#ifeq: {{:Friendly data|{{{1}}}|Occupation}}|NPC {{{1}}} does not exist in [[Friendly data]].||{{:Friendly data|{{{1}}}|Occupation}}}}}}<!--
     -->{{#vardefine:Name|{{:Friendly data|{{{1}}}|Name}}}}<!--
    --- Fetch Buys and Sells data --
     -->{{#vardefine:Trader|{{:Friendly data|{{{1}}}|Trader}}}}<!--
     -->{{#vardefine:Buys|{{:Datastring|{{#var:{{PAGENAME}}}}|Buys}}}}<!--
     -->{{#vardefine:Category|{{{2}}}}}<!--
     -->{{#vardefine:Sells|{{:Datastring|{{#var:{{PAGENAME}}}}|Sells}}}}<!--
     -->{{#vardefine:CategoryData|{{:NPCLoot data|{{{1}}}|{{#var:Category}}}}}}<!--
    --- Define variables for the type and item from the NPC ---
    -->{{#vardefine:NPC|{{{1}}}}} <!-- NPC name ---
    -->{{#vardefine:Trade|{{{1|}}}}} <!-- Buys or Sells ---
     -->{{#vardefine:Category|{{{2|}}}}} <!-- Category of Items ---
    --- Load translations that are used multiple times into variables. ---
    -->{{#vardefine:TranslateCategory|{{Translate|{{{1}}}|Properties}}}}<!--
    --- Load translated description or fallback to base description ---
     --> {{#vardefine:ItemDescription|{{#ifexist:Template:{{uc:{{SUBPAGENAME}}}}_Properties|{{:Template:{{uc:{{SUBPAGENAME}}}}_Properties|{{{1}}}}}|{{#var:ItemDescription}}}}}} <!--
    --- 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. ---
    -->{{#vardefine:Link|{{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}}}<!--
     -->
     -->
     |-
     |- <!-- Second column [Name & Icon inside row] -->
    <!-- Second column -->
     | '''[[{{#var:Link}}|{{#if:{{#var:TranslateName}}|{{#var:TranslateName}}|{{{1}}}}}]]'''<!--
     | Armor<br>[[File:Armor_icon.png|42px|link=|]]
    --><br>[[File:Armor_icon.png|42px|link=|]]
     | {{#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}}}}]]<!--
     | {{#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}}}}]]<!--
     --- Extra images for NPC entries like generic guards or peasants. Many face images with no link. ---
     --- Extra images for NPC entries like generic guards or peasants. Many face images with no link. ---

Revision as of 06:42, 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
Bert
Armor icon.png
Bert.png
BertBuys
    File:Icon.png
{{{2}}})
  • With "head" & "Buys"
Category Types
Bert
Armor icon.png
Bert.png
BertBuys
    File:Icon.png

Sells

  • With "head", "Sells" & "end"
Category Types
Bert
Armor icon.png
Bert.png
BertSells
    File:Icon.png
{{{2}}})
  • With "head|Bert|Sells" & "SellsX3"
Bert Sells
Category Types
Bert
Armor icon.png
Bert.png
BertSells
    File:Icon.png
    
Bert
Armor icon.png
Bert.png
BertSells
    File:Icon.png
    
Bert
Armor icon.png
Bert.png
BertSells
    File:Icon.png
  • With "head" & "SellsX2"
Category Types
Bert
Armor icon.png
Bert.png
BertSells
    File:Icon.png
    
Bert
Armor icon.png
Bert.png
BertSells
    File:Icon.png