Filter overlays
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.
Filter overlays
I have searched the forum and have not found any information and I'd like when I find the right way, it's registered somewhere easy to find, like the forum or the wiki. According to the wiki...:
And I have already seen it used in 3 different addons, without working in any of them, because they are obsolete.
So... what is the proper way to filter now? I don't know how to filter inside modifications because overlays usually have this form inside [unit][modifications]:
Sometimes inside [trait], sometimes inside [object], or other tags with [effect] support.
SOLUTION EXAMPLES:
To filter loyals with loyal icon, typically the "true loyals" (not heroes, leaders, etc...):
To filter heroes with hero icon, for example Delfador in the tutorial:
To filter overlays applied with objects:
IMPORTANT: In some cases, there may be
So a StandardUnitFilter like this will always give empty:overlays: a comma-separated list of images that are overlayed on the unit.
(Version 1.15.0 and later only) This key is supported when creating a unit from WML, but will be empty when writing the unit back to WML; the overlays will instead be stored as [modifications].
Code: Select all
[filter_wml]
overlays="misc/hero-icon.png"
[/filter_wml]
So... what is the proper way to filter now? I don't know how to filter inside modifications because overlays usually have this form inside [unit][modifications]:
Code: Select all
[effect]
add="misc/loyal-icon.png"
apply_to="overlay"
[/effect]
SOLUTION EXAMPLES:
To filter loyals with loyal icon, typically the "true loyals" (not heroes, leaders, etc...):
Code: Select all
[filter_wml]
[modifications]
[trait]
[effect]
apply_to=overlay
add="misc/loyal-icon.png"
[/effect]
[/trait]
[/modifications]
[/filter_wml]
To filter heroes with hero icon, for example Delfador in the tutorial:
Code: Select all
[filter_wml]
[modifications]
[trait]
[effect]
apply_to=overlay
add="misc/hero-icon.png"
[/effect]
[/trait]
[/modifications]
[/filter_wml]
Code: Select all
[filter_wml]
[modifications]
[object]
[effect]
apply_to=overlay
add="misc/hero-icon.png" ## or any other overlay
[/effect]
[/object]
[/modifications]
[/filter_wml]
replace=
instead of add=
, this case should be covered independently with another filter with [or]
Last edited by Toranks on December 23rd, 2022, 4:19 pm, edited 2 times in total.
Re: Filter overlays
I'm not sure about how to do the filter, but maybe this example will help.
From Descent into Darkness, scenario 8.
From Descent into Darkness, scenario 8.
Code: Select all
[unit_overlay]
x,y=$x1,$y1
image="misc/book-icon.png"
object_id="book_icon"
[/unit_overlay]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: Filter overlays
What this code does is add an overlay to the units that meet the StandardUnitFilter conditions. I want to filter overlays themselves as StandardUnitFilter.
Re: Filter overlays
Oh. I don't know how to filter for that.
Maybe you could gave a new status to the unit, along with the overlay, then filter for the status?
Something like...
Maybe you could gave a new status to the unit, along with the overlay, then filter for the status?
Something like...
Code: Select all
[event]
name=new turn
first_time_only=no
[store_unit]
[filter]
side=2
status=has_overlay
[/filter]
variable=target_units
[/store_unit]
[foreach]
array=target_units
[do]
[if]
[variable]
# etc.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: Filter overlays
I already do that, using [objects]. But my intention is to filter by those who already have the units. For example, I want to filter all heroes that have the silver crown from many campaigns. Or filter only loyals who have the loyal bracelet. (There are some loyals without a bracelet)
Re: Filter overlays
It is conceptually not possible with filter_wml. You can filter and see that unit has specific overlay, but it is not possible anymore to check that it is the only overlay.
Re: Filter overlays
How? I'm not interested on detect if is the only overlay. I want to filter a specific overlay, it doesn't matter if the unit have more
Re: Filter overlays
> Sometimes inside [trait], sometimes inside [object], or other tags with [effect] support.
There is limited number of tags where effect can appear, so filter_wml for them all with [or]
There is limited number of tags where effect can appear, so filter_wml for them all with [or]
Re: Filter overlays
Code: Select all
[filter_wml]
[trait]
overlay="misc/hero-icon.png"
[/trait]
[filter_wml]
Re: Filter overlays
Exact tag structure as is in units wml.
Re: Filter overlays
This doesn't makes much sense for me, but is exactly what appears on the [unit] I want to filter
Code: Select all
[filter_wml]
[trait]
[effect]
add="misc/loyal-icon.png"
apply_to="overlay"
[/effect]
[/trait]
[filter_wml]
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Filter overlays
I'm pretty sure that the
[trait]
tag is in inside a [modifications]
tag in that unit's WML. Adding that should fix it.Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Filter overlays
I knew it, I forgot when answering Ravana. It finally worked for me. I edit the first post to include working examples.beetlenaut wrote: ↑December 23rd, 2022, 7:32 am I'm pretty sure that the[trait]
tag is in inside a[modifications]
tag in that unit's WML. Adding that should fix it.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Filter overlays
You can do almost anything with filter_wml. It would be pretty tricky, but I think it should be possible to verify that an overlay is the only overlay if you wanted that. (I won't try to work it out, since no-one said they wanted it.)