Difference between revisions of "Template:Recipe item"

From Captain of Industry Wiki
Jump to: navigation, search
(Support instant recipe without unit (for Thermal Storage))
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><!--
<includeonly><!--


-->{{#if: {{{Name|}}}|<!--
  ** Check if {{{Name}}} is pollution (or empty) **


-->{{#ifeq: <!--
  -->{{#expr: <!--
    -->    {{#ifeq: {{lc:{{{Name|}}} }} | {{#var: pollution_1}} | 1 | 0 }} <!--
    --> or {{#ifeq: {{lc:{{{Name|}}} }} | {{#var: pollution_2}} | 1 | 0 }} <!--
    --> or {{#ifeq: {{lc:{{{Name|}}} }} | {{#var: pollution_3}} | 1 | 0 }} <!--
    --> or {{#ifeq: {{lc:{{{Name|}}} }} | {{#var: pollution_4}} | 1 | 0 }} <!--
  -->}} | 1 | <!--
  -->{{#vardefine: is_pollution| 1 }} | <!--
  -->{{#vardefine: is_pollution| 0 }} <!--
-->}} <!--
  ** Determine if we should display the icon **
-->{{#ifeq: <!--
  -->{{#expr: <!--
    -->    {{#if: {{{Name|}}} | 0 | 1 }} <!--
    --> or ( {{#ifeq: {{lc:{{{Pollution}}} }} | hide | 1 | 0 }} and {{#var: is_pollution}} ) <!--
    --> or ( {{#ifeq: {{lc:{{{Pollution}}} }} | only | 1 | 0 }} and (not {{#var: is_pollution}} )) <!--
  -->}} | 1 | <!-- Do nothing --> | <!--


   ** Draw plus icon **
   ** Draw plus icon **


   -->{{#ifeq: {{lc:{{{Plus|}}} }} | yes |<!--
   -->{{#ifeq: {{lc:{{{Plus|}}} }} | yes | <!--
     --><div class="block">{{#var: img_plus}}</div>|<!--
     --><div class="block">{{#var: img_plus}}</div>| <!--
     -->{{#ifeq: {{lc:{{{Plus|no}}} }} | no | |<!--
     -->{{#ifeq: {{lc:{{{Plus|no}}} }} | no | | <!--
       --><div class="block">{{{Plus}}}</div><!--
       --><div class="block">{{{Plus}}}</div> <!--
     -->}}<!--
     -->}}<!--
   -->}}<!--
   -->}}<!--


   ** Draw item and throughput
   ** Draw item and throughput **
 
  -->{{#vardefine: image_item | [[File:{{{Name}}}.png{{!}}{{{ImageSize|{{#var: imgsz_reg}}}}}{{!}}link={{{Name}}}]] }}<!--
   --><div class="block"><!--
   --><div class="block"><!--
     --><div class="upper">{{#if: {{{Unit|}}} | &nbsp; | {{{Quantity|0}}}&nbsp;{{{Unit|}}} }}</div><!--
     -->{{#switch: {{{Unit|}}} <!--
    -->[[File:{{{Name}}}.png{{!}}{{{ImageSize|{{#var: imgsz_reg}}}}}{{!}}link={{{Name}}}]]<!--
      -->| ? = <!--
    -->{{#if: {{{Unit|}}} | <!--
        --><div class="upper">?</div><!--
      --><div class="lower">{{{Quantity|}}}&nbsp;{{{Unit|}}}</div>|<!--
        -->{{#var: image_item}}<!--
      --><div class="lower blue">{{#expr: 60/{{{Time|1}}}*{{{Quantity|0}}} round 2 }}</div><!--
        --><div class="lower blue">?</div><!--
      -->| | % = <!--    No unit or %
        -->{{#ifeq: {{{Time|0}}} | 0 <!--
          -->| <div class="upper">&nbsp;</div><!--
          -->{{#var: image_item}}<!--
          --><div class="lower">{{{Quantity|}}}</div><!--
          -->| <div class="upper"><!--
            -->{{#ifeq: {{{Quantity|0}}} | 0 || {{{Quantity|}}} }}{{#if:{{{Unit|}}} | &nbsp;{{{Unit|}}} }}<!--
          --></div><!--
          -->{{#var: image_item}}<!--
          --><div class="lower blue"><!--
            -->{{#ifeq: {{{Quantity|0}}} | 0 ||{{#expr: 60/{{{Time|1}}}*{{{Quantity|0}}} round 2 }} }}<!--
            -->{{#if:{{{Unit|}}} | &nbsp;{{{Unit|}}} }}<!--
          --></div><!--
        -->}}<!--
      -->|#default = <!--
        --><div class="upper">&nbsp;</div><!--
        -->{{#var: image_item}}<!--
        --><div class="lower">{{{Quantity|}}}&nbsp;{{{Unit|}}}</div><!--
     -->}}<!--
     -->}}<!--
   --></div><!--
   --></div><!--
-->}}<!--
-->}}<!--
</includeonly><noinclude>{{documentation}}</noinclude>
--></includeonly><noinclude>{{documentation}}</noinclude>

Latest revision as of 14:34, 16 May 2023

Template documentation (for the above template, sometimes hidden or invisible) [view] [edit] [history] [refresh]
Purpose
This is a template for improving the maintainability of Template: Recipe draw, where the code for drawing the plus sign and item icon is used nearly 20 times. This template is intended to be used ONLY in Template: Recipe draw and does not work alone.
Usage
The template accepts the following parameters:
  • Name: Name of item (example: Iron Ore). If empty string, does not display anything.
  • Quantity: Amount of consumed or produced item per 1 cycle of recipe.
  • Time: Cycle time of recipe.
  • Unit = MW or something (optional): Adds unit to Quantity.
  • Plus = yes (optional): Displays "+" icon left of item icon
    • Plus = something (optional, rare): Displays specified icon (or text) instead of "+" icon
  • Pollution = only (optional): Displays icon only if the item is Air Pollution or Water Pollution
  • Pollution = hide (optional): Displays icon only if the item is NOT Air Pollution or Water Pollution
  • ImageSize = something (optional, rare): Changes size of the item icon

Examples

For Input1 and Output1
Markup Renders as
  {{Recipe item
    | Name     = Steam Hi
    | Quantity = 2
    | Time     = 10
  }}
2
Steam Hi.png
12
For Input2-6 and Output2-6
Markup Renders as
  {{Recipe item
    | Name      = Steam Hi
    | Quantity  = 2
    | Time      = 10
    | Plus      = yes
  }}
Plus.png
2
Steam Hi.png
12
For Mechanical Power and Electricity
Markup Renders as
  {{Recipe item
    | Name      = Electricity
    | Quantity  = 2
    | Unit      = MW
  }}
 
Electricity.png
2 MW
For Instant recipe
Markup Renders as
  {{Recipe item
    | Name      = Steam Depleted
    | Quantity  = 1
    | Time      = 0
  }}
 
Steam Depleted.png
1
For variable quantity
  • For displaying "?," Unit should be used instead of Quantity since Input1Qty, etc. in Template: Recipe define can receive only integer.
Markup Renders as
  {{Recipe item
    | Name      = Steam Hi
    | Unit      = ?  <!-- NOT Quantity -->
    | Time      = 10
  }}
?
Steam Hi.png
?
For hiding pollution
Markup Renders as
  {{Recipe item
    | Name      = Steam Hi
    | Quantity  = 2
    | Time      = 10
    | Pollution = hide
  }}
2
Steam Hi.png
12
  {{Recipe item
    | Name      = Air Pollution
    | Quantity  = 2
    | Time      = 10
    | Pollution = hide
  }}
For showing only pollution
Markup Renders as
  {{Recipe item
    | Name      = Steam Hi
    | Quantity  = 2
    | Time      = 10
    | Pollution = only
  }}
  {{Recipe item
    | Name      = Air Pollution
    | Quantity  = 2
    | Time      = 10
    | Pollution = only
  }}
2
Air Pollution.png
12
When Name is empty
Markup Renders as
  {{Recipe item
    | Name      = 
    | Quantity  = 2
    | Time      = 10
  }}
For overwriting plus icon and/or icon size
Markup Renders as
  {{Recipe item
    | Name      = Steam Hi
    | Quantity  = 2
    | Time      = 10
    | Plus      = [[File:Unity.png|32x32px]]
    | ImageSize = 24x24px
  }}
Unity.png
2
Steam Hi.png
12

Reason this template cannot be used alone

This template depends on the following codes in Template: Recipe draw to define its style and some parameters.
  • <templatestyles src="Template:Recipe draw/styles.css" />
  • <div class="recipe-wrapper>
  • {{#vardefine: img_plus | [[File:Plus.png|24x24px]] }}
  • {{#vardefine: imgsz_reg | 48x48px }}
  • {{#vardefine: pollution_1 | air pollution }}
  • {{#vardefine: pollution_2 | water pollution }}
  • {{#vardefine: pollution_3 | }}
  • {{#vardefine: pollution_4 | }}
The above text is transcluded from Template:Recipe item/doc; you can change it or view its history. (How does this work?)
If you're done making changes, please refresh the text. (Why?)
You can experiment in this template's sandbox (edit | diff) and testcases (create) pages.
Please add categories and interwikis to Template:Recipe item/doc. (View all subpages of this page.)