Dare to try out the Harvest Festival 2024!?
Template:Synthesis Recipe.RecipeList: Difference between revisions
From HorizonXI Wiki
(trying a template to generate recipe lists, although not working properly yet) |
m (some code improvements and a lot of commentary) |
||
Line 1: | Line 1: | ||
<includeonly><onlyinclude>- {{#ifeq:{{lc:{{{1}}}}}|none|style="display: none;"|<!-- | <includeonly><onlyinclude>-<!-- | ||
-->{{#ifeq:{{{ | clever ways to not show desynth recipes and recipes where the item is the | ||
-->{{#ifeq:{{{hq result}}}|this|style="display: none;" | -->{{#ifeq:{{lc:{{{1}}}}}|none|style="display: none;"}}<!-- | ||
-->{{#ifeq:{{{ | if the recipe has only one ingredient with quantity one, then it is by definition a desynthesis of that ingredient (there might be exceptions...) | ||
-->{{#if:{{{ingredient 2|}}}{{{ingredient quantity|}}}||style="display: none;"}}<!-- | |||
if the item is the ingredient of the recipe, then it is a desynthesis recipe. Unfortunately, in a phantom template it seems not possible to use %PAGE% or %TITLE% to check if the pagename is equal to the ingredient, so we can only check against the "keyword" "this". | |||
-->{{#ifeq:{{{ingredient}}}|this|style="display: none;"|}}<!-- | |||
if neither cap, crystal nor result (could add more) is given, then do not display the recipe because it isnt filled out | |||
-->{{#if:{{{cap|}}}{{{crystal|}}}{{{result|}}}||style="display:none;"}}<!-- | |||
there is a another complicated case: if an item is obtainable as a HQ from a synth, that page will list the recipe. But that needs to be removed from the table because the recipe will be listed under what is the NQ. The check for that is tricky because it needs to check that: | |||
- HQ == this (cant detect pagename, need to use "this") | |||
- result != HQ (because it might just be the same, e.g. items where the HQ is just more quantity) | |||
and the same for HQ2 and HQ3 | |||
the occurences which are still in the table are then pages where "this" has not been used by the full name of the item. Because the .dpl template cannot check equality between a parameter and the page's name, there is no way to know whether we are looking at the recipe from the NQ page (stay in table) or the HQ page (should not be in table). | |||
-->{{#ifeq:{{{hq result}}}|{{{result}}}||{{#ifeq:{{{hq result}}}|this|style="display:none;"}}}}<!-- | |||
-->{{#ifeq:{{{hq 2 result}}}|{{{result}}}||{{#ifeq:{{{hq 2 result}}}|this|style="display:none;"}}}}<!-- | |||
-->{{#ifeq:{{{hq 3 result}}}|{{{result}}}||{{#ifeq:{{{hq 3 result}}}|this|style="display:none;"}}}} | |||
<!-- | |||
Start output code | |||
--> | |||
| | | | ||
[[ | [[%PAGE%|%TITLE%]]{{#if:{{{yield|}}}| x {{{yield}}}}}{{#if:{{{crafting tool|}}}|<br/> {{KeyItem}}[[{{{crafting tool}}}]]}} | ||
{{#if:{{{subcraft|}}}|<nowiki/> | {{#if:{{{subcraft|}}}|<nowiki/> | ||
:{{Craft|{{{subcraft}}}|{{{subcraft cap}}}}}}} | :{{Craft|{{{subcraft}}}|{{{subcraft cap}}}}}}} | ||
Line 11: | Line 30: | ||
| | | | ||
[[{{{crystal}}}]] | [[{{{crystal}}}]] | ||
| | |<!-- first ingredient always exists, there is no recipe with zero ingredients. quantities are optional with 1 being implied if none is given by the synthesis recipe template. Subsequent ingredients are checked if they exist, in a nested fashion --> | ||
<ul><li>[[{{{ingredient}}}]]{{#if:{{{ingredient quantity|}}}| x {{{ingredient quantity}}}}}<!-- | <ul><li>[[{{{ingredient}}}]]{{#if:{{{ingredient quantity|}}}| x {{{ingredient quantity}}}}}</li><!-- | ||
-- | -->{{#if:{{{ingredient 2|}}}|<li>[[{{{ingredient 2}}}]]{{#if:{{{ingredient 2 quantity|}}}| x {{{ingredient 2 quantity}}}}}</li><!-- | ||
-->{{#if:{{{ingredient 3|}}}|<li>[[{{{ingredient 3}}}]] | -->{{#if:{{{ingredient 3|}}}|<li>[[{{{ingredient 3}}}]]{{#if:{{{ingredient 3 quantity|}}}| x {{{ingredient 3 quantity}}}}}</li><!-- | ||
-->{{#if:{{{ingredient 4|}}}|<li>[[{{{ingredient 4}}}]] | -->{{#if:{{{ingredient 4|}}}|<li>[[{{{ingredient 4}}}]]{{#if:{{{ingredient 4 quantity|}}}| x {{{ingredient 4 quantity}}}}}</li><!-- | ||
-->{{#if:{{{ingredient 5|}}}|<li>[[{{{ingredient 5}}}]] | -->{{#if:{{{ingredient 5|}}}|<li>[[{{{ingredient 5}}}]]{{#if:{{{ingredient 5 quantity|}}}| x {{{ingredient 5 quantity}}}}}</li>}}}}}}}}</ul> | ||
| | |<!-- next line is complicated because: if no hq result is specified but a hq yield is specified, the synthesis recipe template will default to using the normal result with the hq yield as the hq. Also, the synthesis recipe allows to use "this" as a keyword to use the page title. all these cases must be caught here --> | ||
{{#if:{{{hq result|}}}|HQ: [[{{{hq result}}}]]{{#if:{{{hq yield|}}}| x {{{hq yield}}}}}<!-- | {{#if:{{{hq result|}}}{{{hq yield|}}}|HQ: [[{{#ifeq:{{{hq result}}}|this|%PAGE%{{!}}%TITLE%|{{{hq result|{{#ifeq:{{{result}}}|this|%PAGE%{{!}}%TITLE%|{{{result}}}}}}}}}}]]{{#if:{{{hq yield|}}}| x {{{hq yield}}}}}<!-- | ||
-->{{#if:{{{hq 2 result|}}}|<br/>HQ2: [[{{{hq 2 result}}}]]{{#if:{{{hq 2 yield|}}}| x {{{hq 2 yield}}}}}<!-- | -->{{#if:{{{hq 2 result|}}}{{{hq 2 yield|}}}|<br/>HQ2: [[{{{hq 2 result|{{#ifeq:{{{result}}}|this|%PAGE%{{!}}%TITLE%|{{{result}}}}}}}}]]{{#if:{{{hq 2 yield|}}}| x {{{hq 2 yield}}}}}<!-- | ||
-->{{#if:{{{hq 3 result|}}}|<br/>HQ3: [[{{{hq 3 result | -->{{#if:{{{hq 3 result|}}}{{{hq 3 yield|}}}|<br/>HQ3: [[{{{hq 3 result|{{#ifeq:{{{result}}}|this|%PAGE%{{!}}%TITLE%|{{{result}}}}}}}}]]{{#if:{{{hq 3 yield|}}}| x {{{hq 3 yield}}}}}<!-- | ||
-->}}}}|''none''}} | |||
-->}}}} | |||
</onlyinclude></includeonly> | </onlyinclude></includeonly> | ||
{{#dpl: | {{#dpl: | ||
|category=Alchemy/ | |category=Alchemy/Apprentice | ||
|notcategory=Alchemy/Subcraft | |notcategory=Alchemy/Subcraft | ||
|include={Synthesis Recipe¦RecipeList.dpl} | |include={Synthesis Recipe¦RecipeList.dpl} | ||
|table=class="horizon-table alchemy-table center-col-2 center-col-3",-,Item,Cap,Crystal,Ingredients,HQ | |table=class="horizon-table alchemy-table center-col-2 center-col-3",-,Item,Cap,Crystal,Ingredients,HQ | ||
|tablesortcol=3 | |tablesortcol=3<!-- need to use +1 here because the additional linebreak at the beginning of the phantom template that is used to apply classes and styles to the rows somehow counts as a column here --> | ||
}} | }} |