Template talk:Base ingredients lookup

From Guild Wars 2 Wiki
Jump to navigationJump to search

Recipes with self-referencing items[edit]

Currently, crafted items that appear in the recipe again have an incorrect amount displayed, e.g.

Quantity Material Buy price (each) Material cost
201 Pile of Bloodstone Dust.pngPile of Bloodstone Dust ... ...
1 Essence of Luck (fine).pngEssence of Luck ... ...
1 Mystic Coin.pngMystic Coin ... ...
2 Obsidian Shard.pngObsidian Shard ... ...
10 Thermocatalytic Reagent.pngThermocatalytic Reagent ... ...
Total crafting cost ...

lists 201 Pile of Bloodstone Dust.pngPile of Bloodstone Dust instead of correctly listing 101 Pile of Bloodstone Dust.pngPile of Bloodstone Dust (100 from the Bloodstone Brick + 1 from the recipe itself).

This is a result from setting {{#vardefine:<item>_quantity_wanted|<initial wanted quantity from the crafted item>}} at top, while it doesn't matter for recipes in general as it isn't considered in the final result, in fact it does matter for self-referencing ones. Hence, I would suggest the following code edit:

[..]

<!-- add one additional line defining initial quantity at top -->
{{#arraymap:{{#var:input_string}}|~|@@@|
  {{#vardefine:ingredients_to_process|{{#var:ingredients_to_process}}~{{#explode:@@@|;|1}}}}
  {{#vardefine:{{#explode:@@@|;|1}}_quantity_wanted|{{#explode:@@@|;|0}}}}
  {{#vardefine:{{#explode:@@@|;|1}}_initial_quantity_wanted|{{#explode:@@@|;|0}}}} <!-- new line -->
  {{#vardefine:{{#explode:@@@|;|1}}_quantity_crafted|0}}
|}}

[..]
|\n}}

<!-- substract initial quantity at the bottom after the loop -->
{{#arraymap:{{#var:input_string}}|~|@@@|
  {{increment|{{#explode:@@@|;|1}}_quantity_wanted|-{{#var:{{#explode:@@@|;|1}}_initial_quantity_wanted|0}}}}
|}}

}}</onlyinclude>

Can anyone verify this potential edit s.t. it doesn't break anything? Then we could remove the following from Pile of Bloodstone Dust:

| base ingredients link = n <!-- base ingredients template does not work when the original output item appears in its own recipe -->
| base ingredients calculation = n <!-- base ingredients template does not work when the original output item appears in its own recipe -->

--Tolkyria (talk) 20:07, 19 October 2020 (UTC)

The solution I posted above it not working for the following (previously found on the Empowered Boneskinner's Spine, already starting with the recipe ingredients), hence I'm discarding the previous approach:
{{base ingredients lookup|
~1;Boneskinner's Spine
~45;Boneskinner Ritual Vial
~5;Amalgamated Draconic Lodestone
~1;Gift of Bones
}}
{{base ingredients table
|item=Empowered Boneskinner's Spine
|{{#var:base_ingredient_list}}
}}
Maybe we should not modify the "quantity wanted" here but instead in the template base ingredients table, when we know the final output item, and substract {{{quantity}}} from {{#var: {{{item}}}_quantity_wanted}} there. Note that I also considered another approach which in theory splits "quantity wanted" into "initial quantity wanted" and "quantity wanted", but I failed at considering all cases here in this template and other templates that rely on it.
Modifying it in the template base ingredients table seems the easiest way. Again, it would be great if someone could confirm this edit. --Tolkyria (talk) 08:45, 20 October 2020 (UTC)
Again wrong, the initial quantity should only get subtracted from the wanted quantity iff the crafted item reoccurres. Either I'm missing the point or this is really tough. --Tolkyria (talk) 14:37, 20 October 2020 (UTC)