Filter unit with object

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
User avatar
Spannerbag
Posts: 539
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Filter unit with object

Post by Spannerbag »

Hi all,
I'm considering rewriting some existing code - in v1.16.8 - to use [object]s as this would reduce bloat and be more elegant.

However I may need to subsequently remove the [object] from individual units.

I may have missed it but if one or more unit(s) is/are given an object, e.g.

Code: Select all

  [object]
    id=some_object
    take_only_once=no
    silent=yes
    duration=scenario			# Or whatever
    [filter]					# Or whatever
      side=2
    [/filter]
    [effect]
...
  [/object]
Is there a way to [filter] these unit(s) by object id (in this case "some_object")?

Usually it's possible to filter by what the [effect] does (ability, special etc.) but that wouldn't work unambiguously in this case.
I had a look at the wiki and there doesn't seem to be anything there?

One way I to do this I suppose would be by using unit variables but I thought I'd ask here first as I often miss the bleedin' obvious :doh:

Any help/suggestions appreciated.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Pentarctagon
Project Manager
Posts: 5567
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Filter unit with object

Post by Pentarctagon »

Moved to the WML Workshop.
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
Ravana
Forum Moderator
Posts: 3017
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Filter unit with object

Post by Ravana »

[filter_wml] will find them.
User avatar
Spannerbag
Posts: 539
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Filter unit with object

Post by Spannerbag »

Pentarctagon wrote: June 22nd, 2023, 4:14 pm Moved to the WML Workshop.
Ooops, apologies, that's where I meant to post... uh, where *did* I post out of interest? :oops:

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Spannerbag
Posts: 539
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Filter unit with object

Post by Spannerbag »

Ravana wrote: June 22nd, 2023, 5:25 pm [filter_wml] will find them.
Thanks, appreciated!

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Pentarctagon
Project Manager
Posts: 5567
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Filter unit with object

Post by Pentarctagon »

Spannerbag wrote: June 23rd, 2023, 12:55 am
Pentarctagon wrote: June 22nd, 2023, 4:14 pm Moved to the WML Workshop.
Ooops, apologies, that's where I meant to post... uh, where *did* I post out of interest? :oops:

Cheers!
-- Spannerbag
Technical Support :P
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply