[terrain] and nested filter_location query *SOLVED*
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.
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
[terrain] and nested filter_location query *SOLVED*
Edit: changed subject to indicate query answered
Hi,
I'm struggling to get
What I'm trying to achieve is when a waterborne enemy leader dies to remove all their castle and keep overlays (atop water terrain).
I do this sort of thing quite often but there are a few wrinkles here that are making life interesting.
Originally I simply removed all overlays that were
This worked fine but due to other stuff that's going on it broke something else in special circumstances.
So I decided to use a nested
The wiki says:
However I can't get it to work.
Both these versions nuke all overlays (
and
yet this alternate logic version - with exactly the same
I'd much prefer to use the more elegant former version but am struggling to see how to get the nested filter to work.
I suspect my old nemesis
Trouble is, whilst removing
Any help or suggestions gratefully received!
Cheers!
-- Spannerbag
Hi,
I'm struggling to get
[terrain]
to work and would like some help please.What I'm trying to achieve is when a waterborne enemy leader dies to remove all their castle and keep overlays (atop water terrain).
I do this sort of thing quite often but there are a few wrinkles here that are making life interesting.
Originally I simply removed all overlays that were
radius=1
around the leader's keep, including the keep location itself.This worked fine but due to other stuff that's going on it broke something else in special circumstances.
So I decided to use a nested
[filter_location]
to extract the hexes of interest... but this nested filter seems to be always ignored?The wiki says:
terrain: the character of the terrain to use. See TerrainCodesWML to see what letter a type of terrain uses.
StandardLocationFilter. This StandardLocationFilter's terrain= key is used for the new terrain, filtering by terrain can be done with a nested StandardLocationFilter: [and]terrain=terrain_string_to_be_filtered_for.
However I can't get it to work.
Both these versions nuke all overlays (
{SIDE}
is 2 and {FILTER}
is x,y=2,3 ):Code: Select all
#define REMOVE_KEEP_DIE_EVENT SIDE FILTER
[event]
name=die
[filter]
side={SIDE}
canrecruit=yes
[/filter]
[terrain]
[and]
{FILTER}
radius=1
[/and]
[filter_location]
terrain="W*^Cov,W*^Kov"
[/filter_location]
terrain="^"
layer=overlay
[/terrain]
[/event]#enddef
Code: Select all
#define REMOVE_KEEP_DIE_EVENT SIDE FILTER
[event]
name=die
[filter]
side={SIDE}
canrecruit=yes
[/filter]
[terrain]
[and]
{FILTER}
[filter_location]
terrain="W*^Cov,W*^Kov"
[/filter_location]
radius=1
[/and]
terrain="^"
layer=overlay
[/terrain]
[/event]#enddef
{SIDE}
and {FILTER}
values - works as expected (or at least doesn't break anything):Code: Select all
#define REMOVE_KEEP_DIE_EVENT SIDE FILTER
[event]
name=die
[filter]
side={SIDE}
canrecruit=yes
[/filter]
[store_locations]
[and]
{FILTER}
radius=1
[/and]
variable=remkeep_temp
include_borders=no
[/store_locations]
[foreach]
array=remkeep_temp
[do]
[if]
[have_location]
x,y=$this_item.x,$this_item.y
terrain="W*^Cov,W*^Kov"
[/have_location]
[then]
[terrain]
x,y=$this_item.x,$this_item.y
terrain="^"
layer=overlay
[/terrain]
[/then]
[/if]
[/do]
[/foreach]
{CLEAR_VARIABLE remkeep_temp}
[/event]#enddef
I suspect my old nemesis
radius
might also be contributing to my problem?Trouble is, whilst removing
radius
correctly nukes the keep it doesn't allow me to test if the nested filter works or not...Any help or suggestions gratefully received!
Cheers!
-- Spannerbag
Last edited by Spannerbag on February 2nd, 2023, 12:30 pm, edited 1 time in total.
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [terrain] and nested filter_location query
The
As gnombat said, I think just using
[terrain]
tag expects a StandardLocationFilter. [filter_location]
is not documented as one of the tags that are valid inside a StandardLocationFilter, so the game is simply ignoring it.As gnombat said, I think just using
[and]
alone should do the trick.- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: [terrain] and nested filter_location query
Many thanks for that - I did wonder if there were examples somewhere but had no idea where to look...
Yeah didn't seem right to me but what mislead me was the wiki phrase:Celtic_Minstrel wrote: ↑February 2nd, 2023, 7:20 am The[terrain]
tag expects a StandardLocationFilter.[filter_location]
is not documented as one of the tags that are valid inside a StandardLocationFilter, so the game is simply ignoring it.
As gnombat said, I think just using[and]
alone should do the trick.
...filtering by terrain can be done with a nested StandardLocationFilter...
Got it working, the code needed two
[and]
s though, one each for [terrain]
and radius
.Code: Select all
#define REMOVE_KEEP_DIE_EVENT SIDE FILTER
[event]
name=die
[filter]
side={SIDE}
canrecruit=yes
[/filter]
[terrain]
[and]
[and]
{FILTER}
radius=1
[/and]
terrain="W*^Cov,W*^Kov"
[/and]
terrain="^"
layer=overlay
[/terrain]
[/event]#enddef
Cheers!
-- Spannerbag