New WML Improvement: Appending Elements
Moderator: Forum Moderators
New WML Improvement: Appending Elements
One of the limiting factors of WML macros is that sometimes only one element is allowed in a certain context, and other elements beyond that will be ignored.
For instance, it has been suggested that the Dwarvish units, who have special resistance definitions inside their [unit] tags, should have a macro {DWARVISH_RESISTANCE} defined. The problem is that each dwarf has slightly different resistance, and if you were to go,
That'd expand to,
and only the first element is inspected in code.
So, I've added a feature to WML: you can specify an element with a '+' prefix. This will create the element as normal, except that if there is an element of the same name in the same scope already, the new element will be appended onto the old, instead of creating a new element.
That is, the code,
(Note the '+' in front of the first [element] tag is optional, and has no effect)
Is the same as,
Hopefully this'll improve the usefulness of macros in WML.
David
For instance, it has been suggested that the Dwarvish units, who have special resistance definitions inside their [unit] tags, should have a macro {DWARVISH_RESISTANCE} defined. The problem is that each dwarf has slightly different resistance, and if you were to go,
Code: Select all
{DWARVISH_RESISTANCE}
#override just one value
[resistance]
blade=70
[/resistance]
Code: Select all
[resistance]
#whatever resistance dwarves have in here
[/resistance]
[resistance]
blade=70
[/resistance]
So, I've added a feature to WML: you can specify an element with a '+' prefix. This will create the element as normal, except that if there is an element of the same name in the same scope already, the new element will be appended onto the old, instead of creating a new element.
That is, the code,
Code: Select all
[+element]
a=1
b=2
[/element]
[+element]
b=4
c=5
[/element]
Is the same as,
Code: Select all
[element]
a=1
b=4
c=5
[/element]
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming