| 04-10-2009, 10:01 PM | #1 |
Like you know there is no function TriggerRemoveEvent, even if all TriggerRegister... returns an event. The only way is to destroy/recreate the trigger with all events, conditions and actions without the specific event, so you need to handle all these things ![]() I've discovered a lame way to disable, (not destroy an event). But it will work only if there is a boolexpr argument to the function TriggerRegister... JASS:library LameWayToDisableAnEvent initializer init globals private boolexpr B1 endglobals private function True takes nothing returns boolean call BJDebugMsg(GetUnitName(GetFilterUnit())) // i didn't test all the event responses but it seems only this one works and is safe, basically it is like the GetTriggerUnit() in a trigger condition / action return true endfunction private function Actions takes nothing returns nothing call BJDebugMsg("ACTIONS") endfunction private function Conditions takes nothing returns boolean call BJDebugMsg("CONDITIONS") return true endfunction private function init takes nothing returns nothing local trigger trig = CreateTrigger() local group grp = CreateGroup() set B1 = Or(Filter(function True),null) call TriggerRegisterPlayerUnitEvent(trig,Player(0),EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER,B1) call TriggerAddAction(trig,function Actions) call TriggerAddCondition(trig,Condition(function Conditions)) call TriggerSleepAction(10.0) call DestroyBoolExpr(B1) // ofc, you have to link the boolexpr to the event if you need it call BJDebugMsg("the event is disabled") endfunction endlibrary Maybe someone will find it a little usefull on specific cases. |
| 04-10-2009, 11:59 PM | #2 |
Have you tried swapping boolexpr's to see if it works correctly with the new filter? |
| 04-11-2009, 12:08 AM | #3 | |
Quote:
"Or" and "And" create a new boolexpr each time they are called. You can only destroy the boolexpr specified in the registered event. If you directly use "Filter" or "Condition" then you don't create a new boolexpr if you had already created it, or destroyed the previous one. EDIT : You want mean that ? JASS:set B1 = Or(null,Filter(function True)) EDIT : You can also use that, if you don't want to code in the boolexpr, which should be avoided anyway. JASS:set B1 = Not(Or(null,null)) |
| 04-11-2009, 04:42 PM | #4 |
Unfortunately GetTriggeringTrigger() and GetTriggerEventId() don't work in a such boolexpr, so there is no way to link the event with a global boolean variable, unless you create one function (Filter(function ...)) and one boolean variable for each boolexpr argument ... If these worked, we could easily make a system that can manage the activation and deactivation of the events. In conclusion, just forget it ![]() |
| 04-19-2009, 07:34 PM | #5 | |
Quote:
Create a linked list with disabled eventids and attach it to the trigger use TriggerAddCondition() to check whether the eventid was any of the disabled ones and return false if yes? |
| 04-19-2009, 10:23 PM | #6 |
It would work only if there are not the same type of events in a same trigger. And also, much more lame, the others trigger conditions will be evaluated. |
