• 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.

How to enable a disabled local trigger?

Status
Not open for further replies.
Level 20
Joined
Aug 13, 2013
Messages
1,696
"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:

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.

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).
 
Level 11
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."
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

Thank you all. :)
 
Status
Not open for further replies.
Top