move unit to recall list
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
- Blitzmerker
- Posts: 50
- Joined: March 20th, 2007, 5:44 pm
- Location: Germany
move unit to recall list
Hello,
I am trying to move all units of one side (exept the leader) to the recall list. I tried thisbut it only moves one unit (the unit with the smallest x and of those units the one with the smallest y) to the recall list, all other units are removed from the game. If the event is triggered multiple times the unit in the recall list is overritten.
How can I move the units to the recall list? (Wesnoth 1.4.2+svn)
I am trying to move all units of one side (exept the leader) to the recall list. I tried this
Code: Select all
[while]
[have_unit]
side=1
[not]
canrecruit=1
[/not]
[/have_unit]
[do]
[store_unit]
variable=addtorecall
[filter]
side=1
[not]
canrecruit=1
[/not]
[/filter]
kill=yes
[/store_unit]
[set_variable]
name=addtorecall.x
value=recall
[/set_variable]
[set_variable]
name=addtorecall.y
value=recall
[/set_variable]
[unstore_unit]
variable=addtorecall
[/unstore_unit]
[/do]
[/while]
How can I move the units to the recall list? (Wesnoth 1.4.2+svn)
:(){ :|:& };:
Re: move unit to recall list
Try PUT_TO_RECALL_LIST in data/core/macros/utils.cfg.
Re: move unit to recall list
There is a major misconception going on in your code:
[store_unit] stores all the units that match the filter into an array-variable so you have to loop over that array with the [while].
something like (but pls note that I'm not fluent in WML):
Or you could just use zoo's advise (that he managed to slip in while I was typing this) that's probably a better approach
/tsr
[store_unit] stores all the units that match the filter into an array-variable so you have to loop over that array with the [while].
something like (but pls note that I'm not fluent in WML):
Code: Select all
[store_unit]
*filter*
variable=non_leader_units
[/store_unit]
[set_variable]
name=iterator
value=0
[/set_variable]
[while]
[variable]
name=iterator
less_than_equals_to=non_leader_units.length
[/variable]
[do]
*do your stuff for every unit accessing it as non_leader_units[$iterator]
[/do]
[/while]
/tsr