| 01-21-2008, 08:18 PM | #1 |
The function TriggerRegisterEnterRegion has, as one of its parameters, a boolexpr; or to be more exact, i'm using it as a filterfunc. I was wondering, exactly how does the boolexpr (filterfunc) work in terms of its relation to the TriggerRegisterEnterRegion? Does it mean that when executing the function TriggerRegisterEnterRegion, the function will only register unit who successfully passed the filter? In other word, does it pick every unit and run them through the filterfunc; and if they pass the filterfunc, they will be register for the "unit enter region" event? If so, what about newly created units; will they be checked against the filter? I am not asking how a filterfunc works. |
| 01-21-2008, 08:20 PM | #2 |
afaik the filterfunc checks the entering unit and if the unit passes those filters the actions added to the trigger will be executed. |
| 01-21-2008, 08:24 PM | #3 | |
Quote:
Wait, so it doesn't actually register the unit for the event beforehand? So this would mean that, when a unit enters a region -- the filterfunc acts as a condition? And if the unit passes the filterfunct, a trigger is made and its action are added? Although, i don't see this can possibly work because if the registering occurs at the instance of the unit entering the region, where does the actual event detection occurs at? The unit is already in the region; it would have to re-enter, would it? |
| 01-21-2008, 08:54 PM | #4 | ||||
Ive used it a few times and it seems as if it is exactly like a triggercondition with the exception that you can use only GetFilterUnit() in it and that it is evaluated before any of the triggers conditions. So you can do stuff like this: JASS:function RegisterUnit takes nothing returns boolean local unit u = GetFilterUnit() // everything here will be run whenever a unit enters // the region return false endfunction function init takes nothing returns nothing local trigger enterTrig = CreateTrigger() local region rectRegion = CreateRegion() call RegionAddRect( rectRegion, bj_mapInitialPlayableArea ) call TriggerRegisterEnterRegion( enterTrig, rectRegion, Filter(function RegisterUnit)) // no need to add an action or a condition since everything you could possibly want to do // you can do inside the filter function (RegisterUnit in this example) endfunction EDIT: Quote:
Quote:
Quote:
Quote:
|
| 01-21-2008, 09:20 PM | #5 |
Interesting, +rep. Quite an awkward behavior for a trigger register function. After re-analyzing the function again: Ok, i see what i misunderstood now. It makes perfect sense now. :P god i feel like such a noob. |
