| 10-21-2009, 07:05 PM | #1 |
JASS:set .onCheck = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(.onCheck,EVENT_PLAYER_UNIT_DEATH) call TriggerAddCondition(.onCheck,Condition(function thistype.onCheckFunc)) call BJDebugMsg(I2S(GetHandleId(.onCheck))) return this endmethod static method onCheckFunc takes nothing returns boolean call BJDebugMsg(I2S(GetHandleId(GetTriggeringTrigger()))) I want to know why does it print 2 different Ids... Am I doing something wrong ? |
| 10-21-2009, 07:40 PM | #2 |
There's a reason the manual says you shouldn't use GetTriggeringTrigger inside methods. In this case, since you placed onCheckFunc bellow the function that is calling it, it is called in another trigger. |
| 10-21-2009, 07:46 PM | #3 | |
Quote:
I mean, the triggers should be the same, shouldn't they? |
| 10-21-2009, 07:53 PM | #4 |
Aha got it, thanks. I guess I missed that part(along with the rest of the manual when I didn't read it xD) |
| 10-21-2009, 08:37 PM | #5 | |
Quote:
|
| 10-22-2009, 07:34 AM | #6 | |
Quote:
So TriggerEvent based method calling will still work (2 triggers, one ID), right? |
| 10-22-2009, 09:54 AM | #7 | |
Quote:
In the latter two cases, GetTriggeringTrigger will return the trigger that is being evaluated/executed instead of the original trigger. |
| 10-22-2009, 10:09 AM | #8 | |
Quote:
Not always true. There are optimizations with methods that cause .evaluate to sometimes compile down to a basic function call. This is really fucking annoying considering .evaluate is a great way to beat the op limit. A solution is to declare the method you want to evaluate as a stub and extend the struct, but that prevents non-evaluate calls. (You have to extend the struct due to optimizations with virtualization. Namely, calling a virtual method on a type that has no children can be dealt with at compile time. I'm not 100% sure Vex actually did this optimization, though.) |
| 10-22-2009, 11:17 AM | #9 |
stub keywords are ignored when the struct has no children. Anyway, I did not know that TriggerEvaluate beat the limit. .evaluate is really meant to be optimizable, so I think I need a new method name for when you actually want to use TriggerEvaluate. |
| 10-22-2009, 12:03 PM | #10 |
The problem is, the evaluate keyword already implies the use of triggerEvaluate, maybe use a different keyword for the action that is meant to be optimizable instead? Something like FunctionName.call()? |
| 10-22-2009, 01:19 PM | #11 | |||
Quote:
Quote:
Quote:
|
| 10-22-2009, 01:53 PM | #12 |
call is already a keyword, so no. Edit: err, the number of cases in which we use evaluate just to call the function is much greater than the number of cases in which we just need to break the limit, nevertheless, if we are hitting the limit , TriggerExecute wouldn't be a bottleneck anyway so .execute is fine... So I'll probably do a new name to force TriggerEvaluate or maybe do nothing. |
| 10-22-2009, 01:57 PM | #13 |
FuncName.invoke() |
| 10-22-2009, 04:39 PM | #14 |
What about. FuncName.run()? |
