From Dark and Darker Wiki

(Changing Template to use calls that work with Merchant Data.)
(Item property name was changed in script. Edited to account for this.)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#arraydefine:craftables|{{Merchant Data|{{{1}}}|Crafts|All}} }}
<includeonly><!--
{{
 
#loop: i
 
|0
If @arg:2 has text
|{{#arraysize:craftables}}
-->{{#if:{{{2|}}}<!--
|<nowiki/>{{#vardefine:craft|{{#arrayindex:craftables|{{#var:i}} }} }}<!--
Use @arg:2
If the ingredient is in the list of ingredients for the craft
-->|{{#arraydefine:craftables|{{{2}}}}}<!--
OR the ingredient is empty, generate the crafting row.
Else use all of the Merchant's crafts
-->{{#if:{{#pos:{{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|ingredients}}|{{{ingredient|}}}}}{{#if:{{{ingredient|}}}||continue}}<!--
-->|{{#arraydefine:craftables|{{Merchant Data|{{{1}}}|Crafts|All}}}}}}<!--
-->|{{GenerateCraftingRow|{{#var:craft}} }} }}
If @arg:ingredient was provided
}}
-->{{#if:{{{ingredient|}}}<!--
</includeonly><noinclude>
AND @arg:ingredient is NOT used in a crafting recipe(s)
Auto creates crafting row
-->|{{#if:{{{{{ingredientcategory|Misc}}} Data|{{{ingredient}}}|incraftingrecipefor}}<!--
Set the craftables array to empty
-->||{{#arraydefine:craftables|}}}}}}<!--
        Otherwise do nothing
 
--><table cellspacing="0" class="wikitable sortable jquery-tablesorter" style="width:70%; min-width:500px; text-align:center; vertical-align:middle; {{#ifeq:{{#arraysize:craftables}}|0|display:none;}}"><!--
--><tr><th style="width:3%">Name</th><th style="width:5%">Ingredients</th><th style="width:2%">Merchant</th></tr><!--
-->{{#loop:i|0|{{#arraysize:craftables}}<!--
-->|<tr><!-- Generate a crafting row for each element in @array:craftables
-->{{#vardefine:craft|{{#arrayindex:craftables|{{#var:i}}}}}}<!--
If @arg:ingredient is in the list of ingredients for @var:craft
OR @arg:ingredient is empty
-->{{#if: {{#pos:{{#vardefineecho:ingredients|{{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|ingredients}} }}|{{{ingredient|}}}}}<!--
-->{{#if:{{{ingredient|}}}||continue}}<!--
-->|{{#vardefine:rarity|{{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|rarity}}}}<!--
-->{{#arraydefine:ingredients|{{#var:ingredients}}}}<!--
--><td>{{Iconbox<!--
-->|{{#if:{{#pos:{{#var:craft}}|Potion}}<!--
-->|{{#explode:{{#var:craft}}| |1|2}}<!--
-->|{{#var:craft}}}}<!--
-->|size =x100px<!--
-->|amount ={{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|quantity}}<!--
-->|caption =<span class="colorrarity{{#var:rarity}}">{{#var:craft}}</span><!--
-->|rarity ={{#var:rarity}} }}</td><!--
--><td>{{#loop:i|0|{{#arraysize:ingredients}}<!--
-->|{{#vardefine:ingredient|{{#arrayindex:ingredients|{{#var:i}}}}}}<!--
-->{{Iconbox|<!--
-->{{#explode:{{#var:ingredient}}|-|1}}<!--
-->|size =x100px<!--
-->|caption =no<!--
-->|amount ={{#explode:{{#var:ingredient}}|-|0}}<!--
-->|rarity=<!--
-->{{#if:{{#explode:{{#var:ingredient}}|-|2}}<!--
-->|{{#explode:{{#var:ingredient}}|-|2}}<!--
-->|{{Misc Data|{{#explode:{{#var:ingredient}}|-|1}}|Rarities}}}}}}}}</td><!--
--><td>[[{{{1}}}]]</td>}}</tr>}}</table><!--
 
--></includeonly><noinclude>
=Parameters=
*1:
**Merchant Name
**default: empty string
*2:
**Item or List of Items separated by commas
**default: empty string
*ingredient:
**ingredient to search for
**default: empty string
*ingredientcategory:
**item category of ingredient <code>{Weapon, Armor, Accessory, Utility, Misc}</code>
**default: <code>Misc</code>
==Example==
==Example==
<pre>
<pre>{{GenerateCraftingTable|Alchemist|ingredient=Gold Coin}}</pre>
{{CraftingTable|
{{GenerateCraftingTable|Alchemist|ingredient=Gold Coin}}
{{GenerateCraftingRows|Alchemist}}
}}
</pre>
{{CraftingTable|
{{GenerateCraftingRows|Alchemist}}
}}
==Example==
==Example==
<pre>
<pre>{{GenerateCraftingTable|Weaponsmith|ingredient=Longsword|ingredientcategory=Weapon}}</pre>
{{CraftingTable|
{{GenerateCraftingTable|Weaponsmith|ingredient=Longsword|ingredientcategory=Weapon}}
{{GenerateCraftingRows|Alchemist|ingredient=Gold}}
}}
</pre>
{{CraftingTable|
{{GenerateCraftingRows|Alchemist|ingredient=Gold}}
}}
==Example==
==Example==
<pre>
<pre>{{GenerateCraftingTable|Alchemist|ingredient=Golden Teeth}}</pre>
{{CraftingTable|
{{GenerateCraftingTable|Alchemist|ingredient=Golden Teeth}}
{{GenerateCraftingRows|Weaponsmith|ingredient=Gold}}
}}
</pre>
{{CraftingTable|
{{GenerateCraftingRows|Weaponsmith|ingredient=Gold}}
}}
==Example==
==Example==
<pre>
<pre>{{GenerateCraftingTable|Weaponsmith|Sterling Blade}}</pre>
{{CraftingTable|
{{GenerateCraftingTable|Weaponsmith|Sterling Blade}}
{{GenerateCraftingRows|Armourer|ingredient=Gold}}
==Example==
}}
<pre>{{GenerateCraftingTable|Alchemist}}</pre>
</pre>
{{GenerateCraftingTable|Alchemist}}
{{CraftingTable|
==Example==
{{GenerateCraftingRows|Armourer|ingredient=Gold}}
<pre>{{GenerateCraftingTable|Alchemist|ingredient=Silver Ore}}</pre>
}}
{{GenerateCraftingTable|Alchemist|ingredient=Silver Ore}}
</noinclude>
</noinclude>

Latest revision as of 06:53, 23 June 2024

Parameters

  • 1:
    • Merchant Name
    • default: empty string
  • 2:
    • Item or List of Items separated by commas
    • default: empty string
  • ingredient:
    • ingredient to search for
    • default: empty string
  • ingredientcategory:
    • item category of ingredient {Weapon, Armor, Accessory, Utility, Misc}
    • default: Misc

Example

{{GenerateCraftingTable|Alchemist|ingredient=Gold Coin}}
NameIngredientsMerchant
Gold Ingot1
Wolf Fang2
Wolf Claw3
Gold Coin300
Alchemist
Gold Ingot1
Golden Teeth1
Gold Coin300
Alchemist

Example

{{GenerateCraftingTable|Weaponsmith|ingredient=Longsword|ingredientcategory=Weapon}}
NameIngredientsMerchant
Longsword1
Dark Matter1
Gold Ingot3
Gold Coin50
Weaponsmith
Longsword1
Silver Powder2
Weaponsmith
Longsword1
Silver Ingot2
Weaponsmith
Longsword1
Silver Ingot3
Weaponsmith

Example

{{GenerateCraftingTable|Alchemist|ingredient=Golden Teeth}}
NameIngredientsMerchant
Gold Ingot1
Golden Teeth1
Gold Coin300
Alchemist

Example

{{GenerateCraftingTable|Weaponsmith|Sterling Blade}}
NameIngredientsMerchant
Longsword1
Silver Powder2
Weaponsmith

Example

{{GenerateCraftingTable|Alchemist}}
NameIngredientsMerchant
Iron Ore2
Alchemist
Copper Ore2
Alchemist
Cobalt Ore2
Alchemist
Rubysilver Ore2
Alchemist
Silver Coin45
Alchemist
Gold Ore2
Alchemist
Froststone Ore2
Alchemist
Gold Ingot1
Wolf Fang2
Wolf Claw3
Gold Coin300
Alchemist
Gold Ingot1
Golden Teeth1
Gold Coin300
Alchemist
Potion of Healing1
Lifeleaf1
Alchemist
Potion of Healing1
Lifeleaf2
Alchemist
Potion of Healing1
Lifeleaf3
Alchemist
Potion of Healing1
Lifeleaf5
Alchemist
Potion of Protection1
Phantom Flower1
Alchemist
Potion of Protection1
Phantom Flower2
Alchemist
Potion of Protection1
Phantom Flower3
Alchemist
Potion of Protection1
Phantom Flower5
Alchemist
Magic Protection Potion1
Wardweed1
Alchemist
Magic Protection Potion1
Wardweed2
Alchemist
Magic Protection Potion1
Wardweed3
Alchemist
Magic Protection Potion1
Wardweed5
Alchemist
Lifeleaf2
Phantom Flower2
Wardweed2
Alchemist
Lifeleaf4
Phantom Flower4
Wardweed4
Alchemist
Lifeleaf6
Phantom Flower6
Wardweed6
Alchemist
Lifeleaf8
Phantom Flower8
Wardweed8
Alchemist

Example

{{GenerateCraftingTable|Alchemist|ingredient=Silver Ore}}