User:Sub4rctic/Any

From TerraFirmaCraft Plus Wiki
Jump to: navigation, search



{{User:Sub4rctic/Woods}} List of all woods with < and > as PREFIX and SUFFIX, semicolon separated

{{#replace:string|search term|replacement term}} replacement syntax

{{#replace:{{User:Sub4rctic/Woods}}|search term|replacement term}} use the woods template as the string

{{#replace:{{User:Sub4rctic/Woods}}|>|<nowiki/> <nowiki/>SUFFIX}} If a space is used in the replacement term, must be nowiki'd out with self-closing tags

{{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX}}|<|PREFIX}} nest SUFFIX replacement inside a PREFIX replacement

{{#explode:string|delimiter|position|limit}} explode syntax. Pos counted from 0

{{#explode:{{{1}}}|,|0}} Returns before comma

{{#explode:{{{1}}}|,|1}} returns string after comma

{{#vardefine:Item|{{#explode:{{{1}}}|,|0}}}}
{{#vardefine:Quantity|{{#explode:{{{1}}}|,|1}}}}

Set variables to make code more readable.

{{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX,{{#var:Quantity}}}}|<|PREFIX}} after the suffix add a comma and add param 1 string after comma. Problem: leaves a comma even when there is no ",#" after item name.

{{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }} if syntax

{{#if: {{#var:Quantity}}|,{{#var:Quantity}}|}} if param 1 string after comma delimiter is not empty, return ", string", and if it is, return nothing

{{#replace: {{#replace: {{User:Sub4rctic/Woods}}|>|SUFFIX{{#if:{{#var:Quantity}}|,{{#var:Quantity}}|}}}}|<|PREFIX}} so if param 1 has a comma then number, a comma and the number will be placed after SUFFIX. If not, then nothing will be placed after SUFFIX

{{#switch: comparison string
 | case = result
 | case = result
 | #default = default result
}}

Switch syntax