Difference between revisions of "Template:Acquired from"

From Stoneshard wiki
Jump to navigation Jump to search
(updated to 0.8.1.8)
(new datastring format)
Line 1: Line 1:
<includeonly><!--
<includeonly><!--
--><!-- Check if item has data in Armor data or Weapon data, define appropriate data page as variable --><!--
--><!-- Check if item has data in Armor data or Weapon data, define appropriate data page as variable --><!--
-->{{#vardefine:Datapage|{{#ifeq:{{:Weapon_data|{{ROOTPAGENAME}}|LVL}}|Data does not exist.|{{#ifeq:{{:Armor_data|{{ROOTPAGENAME}}|LVL}}|Data does not exist.||Armor_data}}|Weapon_data}}}}<!--
-->{{#vardefine:Datapage|{{#ifeq:{{:Weapon_data|{{ROOTPAGENAME}}}}|Data does not exist.|{{#ifeq:{{:Armor_data|{{ROOTPAGENAME}}}}|Data does not exist.||Armor_data}}|Weapon_data}}}}<!--
--><!-- if item isn't in either data page, just return empty string for now--><!--
--><!-- if item isn't in either data page, just return empty string for now--><!--
-->{{#if:{{#var:Datapage}}|<!--
-->{{#if:{{#var:Datapage}}|<!--
--><!-- Load item data into variables --><!--
--- Load complete datastring into a variable - to only load from the data page once. ---
-->{{#vardefine:Material|{{lc:{{:{{#var:Datapage}}|{{ROOTPAGENAME}}|Material}}}}}}<!--
-->{{#vardefine:Datastring|{{:{{#var:Datapage}}|{{ROOTPAGENAME}}}}}}
-->{{#vardefine:Tags|{{lc:{{:{{#var:Datapage}}|{{ROOTPAGENAME}}|Tags}}}}}}<!--
--><!-- Load item data into variables, temporary solution for armor and weapons only --><!--
-->{{#vardefine:LVL|{{:{{#var:Datapage}}|{{ROOTPAGENAME}}|LVL}}}}<!--
-->{{#ifeq:{{#var:Datapage}}|Armor_data|{{#vardefine:Material|{{lc:{{#explode: {{#var:Datastring}}|;|5}}}}}}|{{#vardefine:Material|{{lc:{{#explode: {{#var:Datastring}}|;|3}}}}}}}}<!--
--><!-- RINGS and AMULETS are only sold by JEWELERS, GENERAL MERCHANTS, PAWNSHOP and DOCK ELF, define a variable to easily skip others --><!--
-->{{#ifeq:{{#var:Datapage}}|Armor_data|{{#vardefine:Tags|{{lc:{{#explode: {{#var:Datastring}}|;|72}}}}}}|{{#vardefine:Tags|{{lc:{{#explode: {{#var:Datastring}}|;|72}}}}}}}}<!--
-->{{#vardefine:Jewelry|{{#pos: ring|{{lc:{{:{{#var:Datapage}}|{{ROOTPAGENAME}}|ArmorType}}}}}}{{#pos: amulet|{{lc:{{:{{#var:Datapage}}|{{ROOTPAGENAME}}|ArmorType}}}}}}}}<!--
-->{{#ifeq:{{#var:Datapage}}|Armor_data|{{#vardefine:LVL|{{#explode: {{#var:Datastring}}|;|1}}}}|{{#vardefine:LVL|{{#explode: {{#var:Datastring}}|;|5}}}}}}<!--
--><!-- RINGS and AMULETS are only sold by JEWELERS, GENERAL MERCHANTS, PAWNSHOP, DOCK ELF and DWARF, define a variable to easily skip others --><!--
-->{{#ifeq:{{#var:Datapage}}|Armor_data|{{#vardefine:Jewelry|{{#pos: ring|{{lc:{{#explode: {{#var:Datastring}}|;|2}}}}}}{{#pos: amulet|{{lc:{{#explode: {{#var:Datastring}}|;|2}}}}}}}}}}<!--
--><!-- Define LVL adjustments at reputation levels into variables --><!--
--><!-- Define LVL adjustments at reputation levels into variables --><!--
-->{{#vardefine:Hatred|-4}}<!--
-->{{#vardefine:Hatred|-4}}<!--
Line 19: Line 21:
--><!-- List all the merchants and remove lines based on variables. --><!--
--><!-- List all the merchants and remove lines based on variables. --><!--
--><!-- Check if item is JEWELRY, skip merchants that can't sell jewelry to lessen the load --><!--
--><!-- Check if item is JEWELRY, skip merchants that can't sell jewelry to lessen the load --><!--
-->{{#if: {{#var:Jewelry}}||
-->{{#if: {{#var:Jewelry|}}||
<!-- Using pos to check if item's material type is sold by the merchant. --><!--
<!-- Using pos to check if item's material type is sold by the merchant. --><!--
--><!-- TAILORS only sell CLOTH and LEATHER --><!--
--><!-- TAILORS only sell CLOTH and LEATHER --><!--

Revision as of 00:18, 1 June 2023

Template-info.png Documentation

This template automatically provides a list of loot sources (where an item can spawn/who drops an item). It is incomplete, a work in progress.


Usage

Call this template from any item page, place it where you want to have a list of sources. No parameter is required, ie. simply copy this text:

{{Acquired from}}


How does it work? (OLD WAY)

  • The template automatically uses the page name as the string to look for.
  • We check if the string we're looking for is part of a data string from a given container page.
  • If a match is found, we display the source's page name. If not, we display nothing.
  • Template assumes that all pages we check have their loot data available in our Data Structure format.
  • Due to the #pos Parser Function limitation, the loot data strings must have less than 1000 characters.


Live Examples

Example of loot data from Hero Sarcophagus:

<includeonly>{{#switch: {{{1}}}
|Loot = Pig-Faced Bascinet, Ceremonial Cuirass, Bollock Dagger, Footman Sword, Rondel, Bastard Sword, Battle Axe, War Pick, Knight Warhammer, Fancy Sword, Decorated Dagger, Orient Staff, Golden Ring, Pearl Necklace, Golden Fancy Ring, Golden Patterned Ring, Sapphire Pendant, Emerald, Sapphire, Sea Pearls, Ruby Beads, Exquisite Casket, Golden Earrings, Amethyst, Aquamarine, Topaz, Golden Brooch, Old Agraffe, Silver Buckle, Golden Cup, Diamond, Ruby
|#default = 
}}</includeonly>

If a container's loot data has more than 1000 characters, the data structure can be organized into multiple entries, for example based on item types.

Example of loot data from Bookshelves:

<includeonly>{{#switch: {{{1}}}
|Loot = Plague Doctor Mask, Brynn Vermouth, Mannshire Fortified, Brandy, Lockpicks, Repair Kit, Crowbar, Surgeon's Kit, Horsetail, Peppermint, Mindwort, Burdock, Bogbean, Agrimony, Vivifying Essence, Gwynnel's Elixir, Healing Salve, Splint, Bandage, Ether Inhaler, Antitoxin, Identification Scroll, Enchantment Scroll, Disenchantment Scroll, Bolt of Cloth, Silver Cup, Hourglass, Jade Figurine, Spool of Thread, Silver Buckle, Silver Plate, Decorated Inkpot, Golden Candelabrum, Silver Cutlery, Bottle of Oil, Iron Ingot, Gold Nugget, Silver Nugget, Copper Candlestick, Bottle, Candle-end, Straw, Coal Chunk, Nails, Ladle, Mug, Bowl, Pot, Plate, Rag, Rope
|Treatise = Sword Treatise I, Sword Treatise II, Sword Treatise III, Axe Treatise I, Axe Treatise II, Axe Treatise III, Mace Treatise I, Mace Treatise II, Mace Treatise III, Dagger Treatise I, Dagger Treatise II, Dagger Treatise III, Greatswords Treatise I, Greatswords Treatise II, Greatswords Treatise III, Ranged Weapons Treatise I, Ranged Weapons Treatise II, Ranged Weapons Treatise III, Shields Treatise I, Shields Treatise II, Shields Treatise III, Staffs Treatise I, Staffs Treatise II, Staffs Treatise III, Combat Mastery Treatise I, Combat Mastery Treatise II, Combat Mastery Treatise III, Combat Mastery Treatise IV, Athletics Treatise I, Athletics Treatise II, Athletics Treatise III, Athletics Treatise IV, Pyromantic Treatise I, Pyromantic Treatise II, Pyromantic Treatise III, Pyromantic Treatise IV, Geomantic Treatise I, Geomantic Treatise II, Geomantic Treatise III, Geomantic Treatise IV
|#default = 
}}</includeonly>

For each parameter you have to add a new line to the template to check for. Example:

-->{{#if: {{#pos:{{:Bookshelves|Loot}}|{{ROOTPAGENAME}}}} | * [[Bookshelves]] | }}<!--
-->{{#if: {{#pos:{{:Bookshelves|Treatise}}|{{ROOTPAGENAME}}}} | * [[Bookshelves]] | }}<!--