Difference between revisions of "Template:BlockVolume"

From Space Engineers Wiki
Jump to: navigation, search
m (Replaced placeholders with parameters)
m (Added parameter volumeonly, code cleanup)
Line 1: Line 1:
<includeonly>{{#switch: {{{2|}}}
+
<includeonly>
| small = {{#vardefineecho:blockwidth|{{#show: {{{1|}}}|?swidth}}}}&times;{{#vardefineecho:blockheight|{{#show: {{{1|}}}|?sheight}}}}&times;{{#vardefineecho:blockdepth|{{#show: {{{1|}}}|?sdepth}}}} ({{#expr: {{#var:blockwidth}}*{{#var:blockheight}}*{{#var:blockdepth}}*0.125 }}&nbsp;m<sup>3</sup>)
+
{{#vardefine:blockwidth | {{#show: {{{1|}}}|? {{#switch: {{{2}}}| large = lwidth | small = swidth}}}}}}
| large = {{#vardefineecho:blockwidth|{{#show: {{{1|}}}|?lwidth}}}}&times;{{#vardefineecho:blockheight|{{#show: {{{1|}}}|?lheight}}}}&times;{{#vardefineecho:blockdepth|{{#show: {{{1|}}}|?ldepth}}}} ({{#expr: {{#var:blockwidth}}*{{#var:blockheight}}*{{#var:blockdepth}}*15.625 }}&nbsp;m<sup>3</sup>)
+
{{#vardefine:blockheight| {{#show: {{{1|}}}|? {{#switch: {{{2}}}| large = lheight | small = sheight}}}}}}
}}</includeonly><noinclude>
+
{{#vardefine:blockdepth | {{#show: {{{1|}}}|? {{#switch: {{{2}}}| large = ldepth | small = sdepth}}}}}}
 +
{{#vardefine:blockvolume | {{#expr: {{#var:blockwidth}} * {{#var:blockheight}} * {{#var:blockdepth}} * {{#switch:{{{2}}} | large = 15.625 | small = 0.125}}}}}}
 +
{{#if:{{{volumeonly|}}} | {{#var:blockvolume}} | {{#var:blockwidth}}&times;{{#var:blockheight}}&times;{{#var:blockdepth}} ({{#var:blockvolume}}&nbsp;m<sup>3</sup>)}}
 +
</includeonly><noinclude>
 +
 
 
Displays block dimensions and calculates its volume.
 
Displays block dimensions and calculates its volume.
  
Line 11: Line 15:
 
<pre>{{BlockVolume|Large Thruster|large}}</pre>
 
<pre>{{BlockVolume|Large Thruster|large}}</pre>
 
Gives {{BlockVolume|Large Thruster|large}}
 
Gives {{BlockVolume|Large Thruster|large}}
 +
<pre>{{BlockVolume|Large Thruster|large|volumeonly=yes}}</pre>
 +
Gives {{BlockVolume|Large Thruster|large|volumeonly=yes}}
 
</noinclude>
 
</noinclude>

Revision as of 16:58, 27 March 2020


Displays block dimensions and calculates its volume.

Usage:
{{BlockVolume|Block name|size}}

Where Block name is the page of the block and size is small or large for respective the block size.

{{BlockVolume|Large Thruster|small}}

Gives ×× (Expression error: Unexpected * operator. m3)

{{BlockVolume|Large Thruster|large}}

Gives ×× (Expression error: Unexpected * operator. m3)

{{BlockVolume|Large Thruster|large|volumeonly=yes}}

Gives Expression error: Unexpected * operator.