Difference between revisions of "Template:BoM"
Line 6: | Line 6: | ||
{{#vardefine: outputBuffer | {{#vardefine: outputBuffer | ||
| {{#ask: | | {{#ask: | ||
− | [[-Has subobject::{{#var: recipeSource}}]] [[Crafting ingredient.ItemType::+]] [[Crafting ingredient.ItemType::!Recipe (Item)]] [[Crafting ingredient.ItemType::!Piece of Equipment]] | + | [[-Has subobject::<!--Lion Helmet-->{{#var: recipeSource}}]] [[Crafting ingredient.ItemType::+]] [[Crafting ingredient.ItemType::!Recipe (Item)]] [[Crafting ingredient.ItemType::!Piece of Equipment]] |
|mainlabel=- | |mainlabel=- | ||
|headers=hide | |headers=hide | ||
Line 43: | Line 43: | ||
--></includeonly><noinclude> | --></includeonly><noinclude> | ||
Generates a BoM (Bill of Materials) for an item. Has three modes: | Generates a BoM (Bill of Materials) for an item. Has three modes: | ||
− | * Show the most basic resources with all amounts added up. (WIP | + | * Show the most basic resources with all amounts added up. (WIP) |
* Show a tree style list with all the needed resources as child of the intermediate ingredient with different levels of indentation (done) | * Show a tree style list with all the needed resources as child of the intermediate ingredient with different levels of indentation (done) | ||
* Show both | * Show both | ||
Line 49: | Line 49: | ||
Uses sub-template [[Template:ResourceBreakdown]] | Uses sub-template [[Template:ResourceBreakdown]] | ||
[[Category:Template]] | [[Category:Template]] | ||
+ | |||
+ | <!-- unfinished code, shouldn't affect pages where this template is used--> | ||
+ | {{#arraydefine: outputBufferList | {{#var: outputBuffer}} | * }} <!-- load tree style BoM list into an array separated by * (generates empty elements for deeper indentations eg: ***)--> | ||
+ | {{#arraydefine: emptyElementArray | * | * }} <!-- generates an array with 2 empty elements (same kind of empty as the ones generated in the step above)--> | ||
+ | {{#arraysize: emptyElementArray}}/{{#arrayprint: emptyElementArray}} | ||
+ | {{#arraydiff: outputBufferList | outputBufferList | emptyElementArray }} <!-- filters out all empty elements from the outputbufferlist array by using the empty elements from emptylementarray as filter comparison--> | ||
+ | {{#arrayslice: outputBufferList | outputBufferList | 1}} <!-- remove the one empty element that somehow makes it through the filter (dont know dont care)--> | ||
+ | {{#arraysize: outputBufferList}}/{{#arrayprint: outputBufferList | <br>}} | ||
+ | {{#arraydefine: basicResources | {{#ask: [[ItemType::Resource]] [[BoolCraft::false]] |mainlabel= |link=none |headers=none |order=asc |sort=ItemID |limit=5000}} }} | ||
+ | {{#vardefine: i | 0}}{{#vardefine: x | 1}}{{#vardefine: totalMana | 0}} | ||
+ | {{#while: <!-- checks every kind of basic resource and adds all occurences into an array--> | ||
+ | | {{#ifexpr: {{#var: i}} < {{#arraysize: basicResources}} | true }} | ||
+ | | {{#vardefine: resourceQuantity | 0 }} | ||
+ | {{#while: | ||
+ | | {{#ifexpr: {{#var: x}} = 1 | true }} | ||
+ | | | ||
+ | }} | ||
+ | {{#vardefine: i | {{#expr: {{#var: i}} + 1 }} }} | ||
+ | }} | ||
</noinclude> | </noinclude> |
Revision as of 17:30, 2 January 2019
Generates a BoM (Bill of Materials) for an item. Has three modes:
- Show the most basic resources with all amounts added up. (WIP)
- Show a tree style list with all the needed resources as child of the intermediate ingredient with different levels of indentation (done)
- Show both
Uses sub-template Template:ResourceBreakdown
2/,
0/
Maximum number of loops have been performed
Maximum number of loops have been performed