Examples of [adjacent_filter]

The place to post your WML questions and answers.

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.
Post Reply
BajMic
Posts: 72
Joined: January 24th, 2023, 1:22 am

Examples of [adjacent_filter]

Post by BajMic »

Hello,

I am reading wiki on it, and I would like to ask for directions to find some comprehensive examples. Ctrl+F on forum gives a lot of results but not what I am looking for.

I need to define locations as "empty hex that belongs to the location A and has adjacent unit on e,ne orse, but no adjacent units on w, nw or sw".

Thanks in advance,
white_haired_uncle
Posts: 1456
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Examples of [adjacent_filter]

Post by white_haired_uncle »

So, don't quote me on this, but I'm pretty sure [filter_adjacent] is a Standard Unit Filter, so you probably can't use it on a location that doesn't contain a unit.

You're probably looking for [filter_location], or [filter_adjacent_location]
Speak softly, and carry Doombringer.
User avatar
Celtic_Minstrel
Developer
Posts: 2371
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Examples of [adjacent_filter]

Post by Celtic_Minstrel »

So, you want the filter to return an empty hex, right? But there must be a unit vaguely to the east? I think something like this should work:

Code: Select all

[filter_location]
	# Ensure there is no unit here.
	[not]
		[filter]
		[/filter]
	[/not]
	[filter_adjacent_location]
		adjacent=e,ne,se
		# Ensure there IS a unit here
		# count=1 # Uncomment this if you want exactly one unit. Otherwise up to 3 adjacent units will match.
		[filter]
		[/filter]
	[/filter_adjacent_location]
	[filter_adjacent_location]
		adjacent=w,nw,sw
		# Ensure there are NO units on any of these spaces
		count=3
		[not]
			[filter]
			[/filter]
		[/not]
	[/filter_adjacent_location]
[/filter_location]
I'm not sure what you mean by "belongs to the location A" though.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply