Enhanced looping tags for WML

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

Moderator: Forum Moderators

gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Enhanced looping tags for WML

Post by gfgtdf »

I wonder whether it makes sense to add a diffenert type of wml loops:
1)A loop that iterates over a comma sperated list like in

Code: Select all

[foreach]
 list="blade,impact,pierce"
 variable="damage_type"
 [do]
  [harm_unit]
   ...
   damage_type="$damage_type"
  [/harm_unit]
 [/do]
[/foreach]
2) A loop that iterates over all childs of wml node (like in iterating over all weapon specialy of an attack, they usually use different tagnames so this canot be done easily with {foreach} )
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Enhanced looping tags for WML

Post by Pentarctagon »

#1 would basically just be a shortcut for [set_variables]/[split], right? That seems like a better candidate for a macro, I think. Either way it would probably make sense to allow the delimiter to be passed in rather than just comma-delimited.

#2 makes sense. To me, the "ideal" solution would be to instead have specials work something like:

Code: Select all

[specials]
  [special]
    effect="marksman"
    ...
  [/special]
[/specials]
though that would probably be more work and would break compatibility with a bunch of add-ons for relatively little gain.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Celtic_Minstrel
Developer
Posts: 2207
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Enhanced looping tags for WML

Post by Celtic_Minstrel »

#2 can already be done easily in Lua (especially since I made vconfigs iterable), so implementing a WML tag based on it shouldn't be too hard.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply