From Dark and Darker Wiki

(Added optional parameter to determine whether to generate the header or not.)
(Default: no header. Optional parameter to display headers. Added logic to no display the table when there are no rows.)
Line 1: Line 1:
<includeonly><!--
<includeonly><!--
Create the crafting rows and store them in the var:rows
-->{{#arraydefine:craftables|{{Merchant Data|{{{1}}}|Crafts|All}} }}<!--
-->{{#arraydefine:craftables|{{Merchant Data|{{{1}}}|Crafts|All}} }}<!--
--><table cellspacing="0" class="wikitable sortable jquery-tablesorter" style="width:55%; min-width:500px; background:transparent; text-align:center; vertical-align:middle;"><!--
-->{{#vardefine:rows|<!--
-->{{#if:{{{header|}}}<!--
-->{{#loop:i|0|{{#arraysize:craftables}}<!--
-->|<tr><th style="font-weight:bold; width:15%">Name</th><th style="font-weight:bold; width:25%">Ingredients</th><th style="font-weight:bold; width:10%">Trader</th></tr>}}<!--
-->|{{#vardefine:craft|{{#arrayindex:craftables|{{#var:i}} }} }}<!--
-->{{#loop:i|0|{{#arraysize:craftables}}
|{{#vardefine:craft|{{#arrayindex:craftables|{{#var:i}} }} }}<!--
If the ingredient is in the list of ingredients for the craft
If the ingredient is in the list of ingredients for the craft
OR the ingredient is empty, generate the crafting row.
OR the ingredient is empty, generate the crafting row.
Line 11: Line 11:
-->{{#if:{{{ingredient|}}}||continue}}<!--
-->{{#if:{{{ingredient|}}}||continue}}<!--
-->|{{#arraydefine:ingredients|{{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|ingredients}} }}<!--
-->|{{#arraydefine:ingredients|{{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|ingredients}} }}<!--
-->{{#vardefine:rarity|{{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|rarity}} }}<!--
--><tr>
--><tr>
<td>{{Iconbox|<!--
<td>{{Iconbox|<!--
Line 18: Line 19:
-->|size=x100px<!--
-->|size=x100px<!--
-->|amount={{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|quantity}}<!--
-->|amount={{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|quantity}}<!--
-->|rarity={{Merchant Data|{{{1}}}|Crafts|{{#var:craft}}|rarity}} }}</td>
-->|caption=<span class="colorrarity{{#var:rarity}}">{{#var:craft}}</span><!--
-->|rarity={{#var:rarity}} }}</td>
<td>{{#loop:i|0|{{#arraysize:ingredients}}<!--
<td>{{#loop:i|0|{{#arraysize:ingredients}}<!--
-->|{{#vardefine:ingredient|{{#arrayindex:ingredients|{{#var:i}} }} }}<!--
-->|{{#vardefine:ingredient|{{#arrayindex:ingredients|{{#var:i}} }} }}<!--
Line 30: Line 32:
-->|{{#explode:{{#var:ingredient}}|-|2}}<!--
-->|{{#explode:{{#var:ingredient}}|-|2}}<!--
-->|{{Misc Data|{{#explode:{{#var:ingredient}}|-|1}}|Rarities}} }} }} }}</td>
-->|{{Misc Data|{{#explode:{{#var:ingredient}}|-|1}}|Rarities}} }} }} }}</td>
<td>[[{{{1}}}]]</td></tr>}} }}</table><!--
<td>[[{{{1}}}]]</td></tr>}} }} }}<!--
 
Use the var:rows to check if we want to display the table.
--><table cellspacing="0" class="wikitable sortable jquery-tablesorter" style="width:55%; min-width:500px; background:transparent; text-align:center; vertical-align:middle; {{#if:{{#var:rows}}||display:none;}}"><!--
--><tr style="font-weight:bold; {{#if:{{{header|}}}||display:none;}}"><th style="width:15%">Name</th><th style="width:25%">Ingredients</th><th style="width:10%">Trader</th></tr><!--
-->{{#var:rows}}</table><!--


--></includeonly><noinclude>
--></includeonly><noinclude>
Creates crafting table
Auto creates crafting row
==Example==
==Example==
<pre>{{GenerateCraftingTable|Alchemist|header=yes}}</pre>
<pre>{{GenerateCraftingTable|Alchemist|header=yes}}</pre>
{{GenerateCraftingTable|Alchemist|header=yes}}
{{GenerateCraftingTable|Alchemist|header=yes}}
==Example==
==Example==
<pre>{{GenerateCraftingTable|Alchemist|ingredient=Gold}}</pre>
<pre>{{GenerateCraftingTable|Alchemist}}</pre>
{{GenerateCraftingTable|Alchemist|ingredient=Gold}}
{{GenerateCraftingTable|Alchemist}}
==Example==
<pre>{{GenerateCraftingTable|Weaponsmith|ingredient=Gold}}</pre>
{{GenerateCraftingTable|Weaponsmith|ingredient=Gold}}
==Example==
==Example==
<pre>{{GenerateCraftingTable|Armourer|ingredient=Gold}}</pre>
<pre>{{GenerateCraftingTable|Alchemist|ingredient=Silver Ore}}</pre>
{{GenerateCraftingTable|Armourer|ingredient=Gold}}
{{GenerateCraftingTable|Alchemist|ingredient=Silver Ore}}
</noinclude>
</noinclude>

Revision as of 00:36, 14 May 2024

Auto creates crafting row

Example

{{GenerateCraftingTable|Alchemist|header=yes}}
NameIngredientsTrader
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}}
NameIngredientsTrader
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}}