Difference between revisions of "Template:NPCLootTable/row"

From Stoneshard wiki
Jump to navigation Jump to search
m (Test)
(New logic working. Still needs tweaks.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><!--  {{NPCLootTable/row|Trade|Type}} ---
<noinclude>'''WORKING: [INCOMPLETE]'''<br>The {{c|+|&#8239}}; Represents a space " ", to not break the reference for the items. {{c|-|DO NOT DELETE}}.</noinclude>
<includeonly><!--  {{NPCLootTable/row|Jurg|Sell|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}}}}}}}<!--
    --- Loads the parameters from the NPC specified in the first parameter ---
     -->{{#vardefine:Exists|{{#ifeq: {{:Friendly data|{{{1}}}|Occupation}}|NPC {{{1}}} does not exist in [[Friendly data]].||{{:Friendly data|{{{1}}}|Occupation}}}}}}<!--
     -->{{#vardefine:Name|{{{1}}}}} <!-- Define NPC name
    --- Fetch Buys and Sells data --
     -->{{#vardefine:Action|{{{2}}}}}<!-- Defines Action = second parameter
     -->{{#vardefine:Buys|{{:Datastring|{{#var:{{PAGENAME}}}}|Buys}}}}<!--
     -->{{#vardefine:Category|{{{3}}}}}<!-- Defines Category = third parameter
     -->{{#vardefine:Sells|{{:Datastring|{{#var:{{PAGENAME}}}}|Sells}}}}<!--
     -->{{#vardefine:DataCategories|{{:NPCLoot data|{{{1}}}}}}}<!-- Fetches data for the specified NPC
    --- Define variables for the type and item from the NPC ---
     -->{{#vardefine:CategoryData|{{#explode:{{#var:DataCategories}}|{{{3}}}}}}}<!-- Fetches the data for the specified category
     -->{{#vardefine:NPC|{{{PAGENAME}}}}} <!-- NPC name ---
     -->{{#vardefine:ItemList|{{#explode:{{:NPCLoot data|{{{1}}}|{{{3}}}}}}}}}<!-- This access the {{{3}}} param directly.
    -->{{#vardefine:Trade|{{{1}}}}} <!-- Buys or Sells ---
     -->{{#vardefine:BuysItemList|{{#explode:{{:NPCLoot data|{{{1}}}|Buys}}}}}}<!-- This access the "Buys" param directly.
    -->{{#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] -->
     |-
     | '''[[{{#var:Link}}|{{#if:{{#var:TranslateName}}|{{#var:TranslateName}}|{{{1}}}}}]]'''<!--
     | width="5%" | {{#ifeq:{{#var:Action}}|Buys|<!--
     --><br>[[File:Armor_icon.png|42px|link=|]]
    --- Action is 'Buys': Display NPC Icon ---
    | {{#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:Name}}|[[File:{{#var:Name}}.png|64px]]|No image found for [[{{#var:Name}}]].}}<br>'''[[{{#var:Name}}]]'''<!--
    --- Extra images for NPC entries like generic guards or peasants. Many face images with no link. ---
     -->}}<!--
    -->{{#if:{{#var:Image2}}|[[File:{{#var:Image2}}|37px|link=]]}}<!--
    -->{{#ifeq:{{#var:Action}}|Sells|
    --><br>{{#if:{{#var:Name}}|{{#if:{{#pos:{{lc:{{#var:Name}}}}|random}}|{{Translate|{{#var:Name}}|NPCNames}}|[[{{Translate|{{#var:Name}}|NPCNames}}]]}}|[[{{Translate|{{{1}}}|NPCNames}}]]}}}}<!--
        <!-- Action is "Sells": Display Category Icons -->
    -->{{#if:{{#var:Exists}}|{{#if:{{:NPCLoot data|{{{1}}}|Quest}}|'''✓'''}}}}{{#if:{{{2|}}}|<sup>{{{2|}}}</sup>}}<!--
        '''{{{3}}}'''<br>{{#if:{{#var:Category}}|[[File:{{#var:Category}}_icon.png|42px]]}}<!--
    <!-- Display items in the specified category -->
    -->}}
    {{#explode:{{#var:CategoryData}}|;|1}} [[File:{{#explode:{{#var:CategoryData}}|;|1}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|1}}]]<!--
    <!-- Second column: Conditional Content -->
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|2}}|{{#explode:{{#var:CategoryData}}|;|2}} [[File:{{#explode:{{#var:CategoryData}}|;|2}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|2}}]]}}<!--
    | {{#ifeq:{{#var:Action}}|Buys|<!-- '''[[{{#if:{{#var:BuysItemList}}|;|0|No category found.}}]]'''
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|3}}|{{#explode:{{#var:CategoryData}}|;|3}} [[File:{{#explode:{{#var:CategoryData}}|;|3}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|3}}]]}}<!--
        --- Action is 'Buys': Display categories ---
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|4}}|{{#explode:{{#var:CategoryData}}|;|4}} [[File:{{#explode:{{#var:CategoryData}}|;|4}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|4}}]]}}<!--
    --><span class="stoneshard sortable" style="display: flex; text-align: center; justify-content: center;"><!-- Flex container ---
    -->{{#if:{{#explode:{{#var:CategoryData}}|;|5}}|{{#explode:{{#var:CategoryData}}|;|5}} [[File:{{#explode:{{#var:CategoryData}}|;|5}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|5}}]]}}<!--
        --><span>'''[[{{#if:{{#explode:{{#var:BuysItemList}}|;|0|No category found.}}}}]]'''<br>{{#if:{{#explode:{{#var:BuysItemList}}|;|0}}|[[File:{{#explode:{{#var:BuysItemList}}|;|0}}_icon.png|64px|link=]]|No icon found.}}</span><!--
     -->{{#if:{{#explode:{{#var:CategoryData}}|;|6}}|{{#explode:{{#var:CategoryData}}|;|6}} [[File:{{#explode:{{#var:CategoryData}}|;|6}}_icon.png|37px|link={{#explode:{{#var:CategoryData}}|;|6}}]]}}<!--
        --><span>'''[[{{#if:{{#explode:{{#var:BuysItemList}}|;|1|No category found.}}}}]]'''<br>{{#if:{{#explode:{{#var:BuysItemList}}|;|1}}|[[File:{{#explode:{{#var:BuysItemList}}|;|1}}_icon.png|64px|link=]]|No icon found }}</span><!--
--></includeonly><noinclude>{{doc|Template:NPCLootTable/row}}[[Category:Templates]]</noinclude>
        --><span>'''[[{{#if:{{#explode:{{#var:BuysItemList}}|;|2|No category found.}}}}]]'''<br>{{#if:{{#explode:{{#var:BuysItemList}}|;|2}}|[[File:{{#explode:{{#var:BuysItemList}}|;|2}}_icon.png|64px|link=]]|No icon found }}</span><!--
        --><span>'''[[{{#if:{{#explode:{{#var:BuysItemList}}|;|3|No category found.}}}}]]'''<br>{{#if:{{#explode:{{#var:BuysItemList}}|;|3}}|[[File:{{#explode:{{#var:BuysItemList}}|;|3}}_icon.png|64px|link=]]|No icon found }}</span><!--
        --><span>'''[[{{#if:{{#explode:{{#var:BuysItemList}}|;|4|No category found.}}}}]]'''<br>{{#if:{{#explode:{{#var:BuysItemList}}|;|4}}|[[File:{{#explode:{{#var:BuysItemList}}|;|4}}_icon.png|64px|link=]]|No icon found }}</span><!--
        --><span>'''[[{{#if:{{#explode:{{#var:BuysItemList}}|;|5|No category found.}}}}]]'''<br>{{#if:{{#explode:{{#var:BuysItemList}}|;|5}}|[[File:{{#explode:{{#var:BuysItemList}}|;|5}}_icon.png|64px|link=]]|No icon found }}</span><!--
        --><span>'''[[{{#if:{{#explode:{{#var:BuysItemList}}|;|6|No category found.}}}}]]'''<br>{{#if:{{#explode:{{#var:BuysItemList}}|;|6}}|[[File:{{#explode:{{#var:BuysItemList}}|;|6}}_icon.png|64px|link=]]|No icon found }}</span><!--
    --></span>}}<!--
     -->{{#ifeq:{{#var:Action}}|Sells|
        <!-- Default Action: Display items -->
        <span class="stoneshard sortable" style="display: flex; text-align: center; justify-content: center;"><!-- Flex container ---
        --><span>{{#if:{{#explode:{{#var:ItemList}}|;|0}}|'''[[{{#replace:{{#explode:{{#var:ItemList}}|;|0}}|_|&#8239;}}]]'''<br>{{#if:{{#explode:{{#var:ItemList}}|;|0}}|[[File:{{#explode:{{#var:ItemList}}|;|0}}.png|64px|link=]]|No image found.}}}}</span><!--
        --><span>{{#if:{{#explode:{{#var:ItemList}}|;|1}}|'''[[{{#replace:{{#explode:{{#var:ItemList}}|;|1}}|_|&#8239;}}]]'''<br>{{#if:{{#explode:{{#var:ItemList}}|;|1}}|[[File:{{#explode:{{#var:ItemList}}|;|1}}.png|64px|link=]]|}}}}</span><!--
        --><span>{{#if:{{#explode:{{#var:ItemList}}|;|2}}|'''[[{{#replace:{{#explode:{{#var:ItemList}}|;|2}}|_|&#8239;}}]]'''<br>{{#if:{{#explode:{{#var:ItemList}}|;|2}}|[[File:{{#explode:{{#var:ItemList}}|;|2}}.png|64px|link=]]|No image found }}}}</span><!--
        --><span>{{#if:{{#explode:{{#var:ItemList}}|;|3}}|'''[[{{#replace:{{#explode:{{#var:ItemList}}|;|3}}|_|&#8239;}}]]'''<br>{{#if:{{#explode:{{#var:ItemList}}|;|3}}|[[File:{{#explode:{{#var:ItemList}}|;|3}}.png|64px|link=]]|No image found }}}}</span><!--
        --><span>{{#if:{{#explode:{{#var:ItemList}}|;|4}}|'''[[{{#replace:{{#explode:{{#var:ItemList}}|;|4}}|_|&#8239;}}]]'''<br>{{#if:{{#explode:{{#var:ItemList}}|;|4}}|[[File:{{#explode:{{#var:ItemList}}|;|4}}.png|64px|link=]]|No image found }}}}</span><!--
        --><span>{{#if:{{#explode:{{#var:ItemList}}|;|5}}|'''[[{{#replace:{{#explode:{{#var:ItemList}}|;|5}}|_|&#8239;}}]]'''<br>{{#if:{{#explode:{{#var:ItemList}}|;|5}}|[[File:{{#explode:{{#var:ItemList}}|;|5}}.png|64px|link=]]|No image found }}}}</span><!--
        --><span>{{#if:{{#explode:{{#var:ItemList}}|;|6}}|'''[[{{#replace:{{#explode:{{#var:ItemList}}|;|6}}|_|&#8239;}}]]'''<br>{{#if:{{#explode:{{#var:ItemList}}|;|6}}|[[File:{{#explode:{{#var:ItemList}}|;|6}}.png|64px|link=]]|No image found }}}}</span>
</span><!--
-->}}</includeonly><noinclude>{{doc|Template:NPCLootTable/row}}[[Category:Templates]]</noinclude>

Latest revision as of 19:05, 27 January 2025

WORKING: [INCOMPLETE]
The &#8239; Represents a space " ", to not break the reference for the items. DO NOT DELETE.

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.png
Bert
[[]]
Armor icon.png
[[]]
Scrolls icon.png
[[]]
Consumables icon.png
[[]]
Jewelry icon.png
[[]]
Loot icon.png
[[]]
Medicine icon.png
[[]]
Other icon.png
{{{2}}})
  • With "head" & "Buys"
Category Types


Bert.png
Bert
[[]]
Armor icon.png
[[]]
Scrolls icon.png
[[]]
Consumables icon.png
[[]]
Jewelry icon.png
[[]]
Loot icon.png
[[]]
Medicine icon.png
[[]]
Other icon.png

Sells

  • With "head", "Sells" & "end"
Category Types


Weapons
Weapons icon.png
Training Crossbow
Training Crossbow.png

{{{2}}})
  • With "head|Bert|Sells" & "SellsX3"
Bert Sells
Category Types


Weapons
Weapons icon.png
Training Crossbow
Training Crossbow.png


Armor
Armor icon.png
Travelling Shoes
Travelling Shoes.png


Tools
Tools icon.png
Hammer
File:Hammer.png
Pickaxe
Pickaxe.png
Bedroll
Bedroll.png

  • With "head" & "SellsX2"
Category Types


Weapons
Weapons icon.png
Training Crossbow
Training Crossbow.png


Tools
Tools icon.png
Hammer
File:Hammer.png
Pickaxe
Pickaxe.png
Bedroll
Bedroll.png