• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Event Filter

Level 12
Joined
Jan 10, 2023
Messages
191
Hello, I know there is an old conversation that says a little on this topic, here - [JASS] Event Filter, but I wanted to get a general opinion on the usefulness of Event Filters, and also if anyone knows any decent tricks to them, I am mostly just curious if they have any real use or any huge drawbacks.

To give an example of the events I am referring to, these are some examples I found of trigger event registering functions that take a boolexpr argument:
  • TriggerRegisterEnterRegion
  • TriggerRegisterLeaveRegion
  • TriggerRegisterPlayerUnitEvent
  • TriggerRegisterFilterUnitEvent
  • TriggerRegisterUnitInRange
I guess my bigger question is can I use event response functions GetTriggerUnit()/ GetTriggerPlayer() in this filter function? Or if only some can be used, which ones?
 
Can be used:

GetFilterUnit()
GetFilterPlayer()
GetFilterItem()
GetFilterDestructable()

Filters can be useful to filter widgets for enumerations to prevent the caller needing to care.
Filters can be defined once, and used at multiple places to prevent logical duplicates.
When Filters are attached to a trigger, they run before actions or condtions. Might become useful for libraries.

If you have no issues to "inline" filtering into the function loop / if statements, then no need to think about using filters.
 
Level 12
Joined
Jan 10, 2023
Messages
191
O, right it should be GetFilter...()! Idk why I thought this filter would be any different in that way.

Typically I only bother using trigger conditions if I have some snippet of a function I could avoid by doing so.
Like if I have some value I would rather set when declaring a local variable to avoid an extra line setting it later and/or if a local is determined by some other function that I could avoid calling.

Thank you!
 
Top