New WML Improvement: Appending Elements

Discussion of all aspects of the game engine, including development of new and existing features.

Moderators: Forum Moderators, Developers

Post Reply
Dave
Founding Developer
Posts: 7066
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

New WML Improvement: Appending Elements

Post by Dave » June 3rd, 2004, 3:59 am

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,

Code: Select all

{DWARVISH_RESISTANCE}

#override just one value
[resistance]
blade=70
[/resistance]
That'd expand to,

Code: Select all

[resistance]
#whatever resistance dwarves have in here
[/resistance]

[resistance]
blade=70
[/resistance]
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,

Code: Select all

[+element]
a=1
b=2
[/element]

[+element]
b=4
c=5
[/element]
(Note the '+' in front of the first [element] tag is optional, and has no effect)

Is the same as,

Code: Select all

[element]
a=1
b=4
c=5
[/element]
Hopefully this'll improve the usefulness of macros in WML.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

Ayin
Inactive Developer
Posts: 294
Joined: March 30th, 2004, 4:45 pm
Location: Nîmes, France
Contact:

Post by Ayin » June 19th, 2004, 9:35 am

Mhhh... This may be used to do even more evil tricks with terrain-graphics WML >:]

Post Reply