• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

General question about general generation

Status
Not open for further replies.
Level 12
Joined
Jun 15, 2016
Messages
472
What is the difference between making a trigger with a local name to making it with the gg_trg prefix?

I searched the tutorials and didn't find anyone referencing that. Is that simply to allow other functions to manipulate said trigger or is there more to it?
 

Deleted member 219079

D

Deleted member 219079

udg user defined global
gg generated global

Avoids interferences.

Note that locals are only accessible in that function, globals are accessible everywhere.
 
They are auto generated, but when you use JASS you have powers to change it.

Be aware that you won't be able anymore to simply refer to the "not gg_trg" trigger:

JASS:
function InitTrig_MyTrigger takes nothing returns nothing
    // You can do like:
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function whatEver )

    // This is by default
    set gg_trg_MyTrigger = CreateTrigger(  )
    call TriggerAddAction( gg_trg_MyTrigger, function whatEver )
endfunction

gg_trg_MyTrigger can still run from GUI actions, while the other one can't.
 
Level 12
Joined
Jun 15, 2016
Messages
472
Right, But assuming I write a trigger which also runs a lot, say twice a second, does it also leak? and if it does how much? the InitTrig function creates a local variable and assigns it to a trigger, so will it do that every time or will the trigger outlive the runtime of it's own functions?
 
function InitTrig_MyTrigger takes nothing returns nothing

^This function runy only once. It gets fired automaticaly by JASS after the map loads. If you change the name from which it was converted to, it won't run anymore.
For example change InitTrig_MyTrigger into function Init and it won't be fired automaticaly anymore.

So this init function runs once, and only once (by itself).
There you create a trigger, bind a TriggerEvent to it, and also define a TriggerAction or TrigerCondition to it.
Now when the event runs, it will run the TriggerCondition and then TriggerAction of the binded trigger.
If it is an periodic event, they will just run periodicly. But the "Init" function itself won't run more often.

I hope it was understandable.
And btw, there is currently no leak.
 
Status
Not open for further replies.
Top