Difference between revisions of "Template:BoM"

From ChatWars Wiki
Jump to: navigation, search
(added the fix for pages with apostrophes)
(added stock weight tally)
Line 31: Line 31:
 
               -->{{#arrayslice: outputBufferList | outputBufferList | 1}} <!-- remove the one empty element that somehow makes it through the filter (dont know dont care)--><!--
 
               -->{{#arrayslice: outputBufferList | outputBufferList | 1}} <!-- remove the one empty element that somehow makes it through the filter (dont know dont care)--><!--
  
               -->{{#arraydefine: neededBasicResources}}{{#arraydefine: neededQuantities}}{{#vardefine: i | 0 }}<!--
+
               -->{{#arraydefine: neededBasicResources}}{{#arraydefine: neededQuantities}}{{#vardefine: totalMana | 0 }}{{#vardefine: totalStock | 0 }}{{#vardefine: i | 0 }}<!--
 
               -->{{#while:
 
               -->{{#while:
 
                   | {{#ifexpr: {{#var: i}} < {{#arraysize: outputBufferList}} | true }}
 
                   | {{#ifexpr: {{#var: i}} < {{#arraysize: outputBufferList}} | true }}
Line 53: Line 53:
 
                       -->{{#arrayslice: quantitiesback | neededQuantities | {{#expr: {{#var: arrayPos}} + 1 }} }}<!--
 
                       -->{{#arrayslice: quantitiesback | neededQuantities | {{#expr: {{#var: arrayPos}} + 1 }} }}<!--
 
                       -->{{#arraymerge: neededQuantities | quantitiesfront | new }}<!--
 
                       -->{{#arraymerge: neededQuantities | quantitiesfront | new }}<!--
                       -->{{#arraymerge: neededQuantities | neededQuantities | quantitiesback }}
+
                       -->{{#arraymerge: neededQuantities | neededQuantities | quantitiesback }}<!--
 +
                      -->{{#vardefine: totalStock | {{#expr: {{#var: totalStock}} + ( {{#var: newQuantity}} * {{#show: {{#var: resource}} |?Weight}} ) }} }}
 
                     }}
 
                     }}
 
                     {{#ifeq: {{#rpos: {{#arrayindex: outputBufferList | {{#var: i}} }} | Mana }} | -1 <!-- checks if the item uses mana to add to the mana tally-->
 
                     {{#ifeq: {{#rpos: {{#arrayindex: outputBufferList | {{#var: i}} }} | Mana }} | -1 <!-- checks if the item uses mana to add to the mana tally-->
Line 73: Line 74:
 
                     {{#vardefine: n | {{#expr: {{#var: n}} + 1 }} }}
 
                     {{#vardefine: n | {{#expr: {{#var: n}} + 1 }} }}
 
                 }}<!--
 
                 }}<!--
               -->[[Mana]] Cost: {{#expr: {{#var: totalMana}} + {{#show: {{#var: recipeSource}} |?ManaCrafting}} }}{{Emoticon|emoticon=Mana}} (Ingredients: {{#var: totalMana}}{{Emoticon|emoticon=Mana}} / Item: {{#show: {{#var: recipeSource}} |?ManaCrafting}}{{Emoticon|emoticon=Mana}})
+
               -->[[Mana]] Cost: {{#expr: {{#var: totalMana}} + {{#show: {{#var: recipeSource}} |?ManaCrafting}} }}{{Emoticon|emoticon=Mana}} (Ingredients: {{#var: totalMana}}{{Emoticon|emoticon=Mana}} / Item: {{#show: {{#var: recipeSource}} |?ManaCrafting}}{{Emoticon|emoticon=Mana}})<br>
 +
<!--          -->Total [[stock]] weight of basic resources: {{#var: totalStock}}{{Emoticon|emoticon=Stock}}
 
}}</div></div><!--
 
}}</div></div><!--
 
--></includeonly><noinclude>
 
--></includeonly><noinclude>

Revision as of 10:08, 9 January 2019

Generates a BoM (Bill of Materials) for an item. Has three modes you can choose with the template parameter outputMode:

  • outputMode = list - Show the most basic resources with all amounts added up.
  • outputMode = tree - Show a tree style list with all the needed resources as child of the intermediate ingredient with different levels of indentation (done)
  • outputMode = all - Show both (Default mode in case parameter is left out)

Uses sub-template Template:ResourceBreakdown