- Joined
- Oct 11, 2012
- Messages
- 711
If I disable a local trigger, how should I enable it afterwards? An answer with a short example is more welcomed. Thanks guys.
Don't use a local trigger if you want to use it that way. Use a global variable instead.
oh lol, i thought..
yeah as chobibo said
local trigger t=CreateTrigger()
i know
You can disable and enable local trigger by do it in the same function..haha (Just kidding ^^)
function Trig_Sentinel_Forests_Conditions takes nothing returns boolean
return IsUnitType(GetEnteringUnit(), UNIT_TYPE_HERO) == true
endfunction
function Trig_Sentinel_Forests_Actions takes nothing returns nothing
call BJDebugMsg("Off")
call DisableTrigger( GetTriggeringTrigger() )
call PolledWait( 5.00 )
call BJDebugMsg("On")
call EnableTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Sentinel_Forests takes nothing returns nothing
local trigger gg_trg_Sentinel_Forests = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Sentinel_Forests, gg_rct_Sentinel_Forest )
call TriggerAddCondition( gg_trg_Sentinel_Forests, Condition( function Trig_Sentinel_Forests_Conditions ) )
call TriggerAddAction( gg_trg_Sentinel_Forests, function Trig_Sentinel_Forests_Actions )
endfunction
Don't forget to null the trigger local handle.
Don't forget to null the trigger local handle.
Dr Super Good said:Yes if you plan to destroy the trigger, otherwise no as the handle index can never be recycled unless the trigger is destroyed.
"If I disable a local trigger, how should I enable it afterwards? An answer with a short example is more welcomed. Thanks guys."
Maybe this:
JASS:function Trig_Sentinel_Forests_Conditions takes nothing returns boolean return IsUnitType(GetEnteringUnit(), UNIT_TYPE_HERO) == true endfunction function Trig_Sentinel_Forests_Actions takes nothing returns nothing call BJDebugMsg("Off") call DisableTrigger( GetTriggeringTrigger() ) call PolledWait( 5.00 ) call BJDebugMsg("On") call EnableTrigger( GetTriggeringTrigger() ) endfunction //=========================================================================== function InitTrig_Sentinel_Forests takes nothing returns nothing local trigger gg_trg_Sentinel_Forests = CreateTrigger( ) call TriggerRegisterEnterRectSimple( gg_trg_Sentinel_Forests, gg_rct_Sentinel_Forest ) call TriggerAddCondition( gg_trg_Sentinel_Forests, Condition( function Trig_Sentinel_Forests_Conditions ) ) call TriggerAddAction( gg_trg_Sentinel_Forests, function Trig_Sentinel_Forests_Actions ) endfunction
@Malhorne:
As DSG said:
But most people tend to null it anyway because:
(1) It isn't bad to do so. (it isn't necessarily beneficial either)
(2) It takes too much time to determine whether you are going to permanently keep the object, and whether it is reference counted (agent) vs. a normal handle (these types do not suffer that local reference bug, e.g. texttags).
Yes better null it since you don't know each time what you will do and it does not matter of speed xD