Difference between revisions of "Template:BoM"

From ChatWars Wiki
Jump to: navigation, search
(updated description)
Line 41: Line 41:
 
                       -->{{#if: {{#var: arrayPos}} <!-- if resource is found (already exists in that array) no new element is added, old element is modified, if not in the array yet, added-->
 
                       -->{{#if: {{#var: arrayPos}} <!-- if resource is found (already exists in that array) no new element is added, old element is modified, if not in the array yet, added-->
 
                           |  
 
                           |  
                           | {{#arraydefine: newResource | {{#var: resource}} }}
+
                           | {{#arraydefine: newResource | {{#var: resource}} }}<!--
                            {{#arraymerge: neededBasicResources | neededBasicResources | newResource }}
+
                          -->{{#arraymerge: neededBasicResources | neededBasicResources | newResource }}<!--
                            {{#arraydefine: newQuantity | 0 }}
+
                          -->{{#arraydefine: newQuantity | 0 }}<!--
                            {{#arraymerge: neededQuantities | neededQuantities | newQuantity }}
+
                          -->{{#arraymerge: neededQuantities | neededQuantities | newQuantity }}<!--
                            {{#vardefine: arrayPos | {{#arraysearch: neededBasicResources | {{#var: resource}} }} }}
+
                          -->{{#vardefine: arrayPos | {{#arraysearch: neededBasicResources | {{#var: resource}} }} }}
                         }}
+
                         }}<!--
                        {{#vardefine: oldQuantitySum | {{#arrayindex: neededQuantities | {{#var: arrayPos}} }} }}
+
                      -->{{#vardefine: oldQuantitySum | {{#arrayindex: neededQuantities | {{#var: arrayPos}} }} }}<!--
                        {{#vardefine: newQuantity | {{#sub: {{#arrayindex: outputBufferList | {{#var: i}} }} | 0 | {{#pos: {{#arrayindex: outputBufferList | {{#var: i}} }} | x }} }} }} <!-- extract quantity from string-->
+
                      -->{{#vardefine: newQuantity | {{#sub: {{#arrayindex: outputBufferList | {{#var: i}} }} | 0 | {{#pos: {{#arrayindex: outputBufferList | {{#var: i}} }} | x }} }} }} <!-- extract quantity from string--><!--
                        {{#arraydefine: new | {{#expr: {{#var: oldQuantitySum}} + {{#var: newQuantity}} }} }}
+
                      -->{{#arraydefine: new | {{#expr: {{#var: oldQuantitySum}} + {{#var: newQuantity}} }} }}<!--
                        {{#arrayslice: quantitiesfront | neededQuantities | 0 | {{#var: arrayPos}} }}
+
                      -->{{#arrayslice: quantitiesfront | neededQuantities | 0 | {{#var: arrayPos}} }}<!--
                        {{#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 }}
 
                     }}
 
                     }}
 
                     {{#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 66: Line 66:
  
  
<!--          -->Basic resource sum:
+
<!--          -->Basic resources sum:
 
                 {{#vardefine: n | 0 }}
 
                 {{#vardefine: n | 0 }}
 
                 {{#while:
 
                 {{#while:
Line 73: Line 73:
 
                     {{#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}})
 
}}</div></div><!--
 
}}</div></div><!--
 
--></includeonly><noinclude>
 
--></includeonly><noinclude>

Revision as of 15:59, 4 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