Talk:SyntaxWML
Empty Values
The workaround I posted was helpful to check whether a variable is initialized:
[variable] name=to_be_tested equals=$empty [/variable]
(tested with wesnoth 1.2.5)
Interesting it doesn't work with [set_variable]format=.
Meriton 15:49, 15 July 2007 (CEST)
Noted by Celtic Minstrel on IRC:
There are two variables, so two pipes should be fine.
In fact, as long as there's whitespace after it, no pipes would also be fine.
The pipe is an optional part of the syntax used to disambiguate where the variable name ends if it's not otherwise clear.
What should happen when the game processes
$metal_reserve$attacker_side||
is:
- Substitute in
$attacker_side|
to get eg$metal_reserve4|
- Substitute in
$metal_reserve4|
to get 12 or whatever.Substitutions always happen from right to left.
And if there's a pipe, the substitution removes it.
So having only 1 pipe would mean that
metal_reserve|stuff
tries to read the variable metal_reserve4stuff instead of metal_reserve4 which is likely not the intention. Thus, always better to match the number of pipes to the number of $'s in this type of situation, unless you know that's not what you want
https://discord.com/channels/231976805987385345/442775044590927873/1078750511475470396