• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Event Filter

Status
Not open for further replies.
Level 14
Joined
Jan 10, 2023
Messages
247
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 14
Joined
Jan 10, 2023
Messages
247
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!
 
Status
Not open for further replies.
Top