HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

3 Questions on triggers

07-20-2007, 03:43 PM#1
darkwulfv
1):Alright. So, my trigger initialization spot looks like this:

Collapse JASS:
function InitTrig_Winning takes nothing returns nothing
  local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( t, 1.50 )
    call TriggerAddAction( t, function Winning_Actions )
set t = null
endfunction

Because it never sets gg_trg_Winning to anything, does that mean gg_trg_Winning has no value to be referred to later? This trigger is off at first, due to conflictions with the globals it refers to (It's integer globals that aren't set to anything above 0 until players choose their hero. if I set them to 0 right off, the game would end in the first 1.5 seconds.) If gg_trg_Winning has no value, how do I use, for example, EnableTrigger()?

2:) When using Enable/DisableTrigger, which WE setting is it referring to? "Enable Trigger", or "Initially on"?

3:) Will enabling a trigger that's already enabled do something bad? Like crash the thread, or reset the trigger, or something else drastic?
07-20-2007, 04:02 PM#2
Silvenon
1) Why don't you use gg_trg_Winning, this way you can't enable that trigger normally. But with handle vars I think you can... I think gg_trg_Winning == null here
2) It is reffering to Initially on/of, when disabling the trigger with Enable/Disable trigger, you can't enable it with triggers.
3) I'm pretty sure it won't, but you can always test it :)
07-20-2007, 04:20 PM#3
Captain Griffen
The global is created anyway, so using a local is pointless.

Triggers disabled in the WE don't exist in the .j file. Triggers disabled in game are deactivated ('initially off' merely disables the trigger in the init function).

Enabling an enabled trigger won't do anything.
07-20-2007, 05:14 PM#4
darkwulfv
Thank you both. The local trigger and all that is supposed to be slightly faster and save a couple bits of memory, or something. Plus it's just become a habit.

So the trigger is set to gg_trg_winning anyways? Cool. Makes my life easy.

Ah, thanks. I didn't know if they meant initially on/off or enabled/disabled.

Good. Last thing I need is thread crashes or stupid crap like that.
07-21-2007, 12:51 PM#5
Silvenon
Quote:
Originally Posted by darkwulfv
The local trigger and all that is supposed to be slightly faster and save a couple bits of memory, or something.

Nope.

Quote:
Originally Posted by darkwulfv
So the trigger is set to gg_trg_winning anyways?

Who said that? A global is created, but I think it's empty, though I could be wrong. If the gg_trg_Winning is that trigger also, then I'm totally confused, it doesn't make any sense.
07-21-2007, 01:49 PM#6
darkwulfv
It works. Trust me. I've got it set up and it runs fine. gg_trg_Winning is a global variable set in the map script whether you set it in it's trigger or not.
07-21-2007, 07:55 PM#7
Anitarf
Yes, however, the variable's value will be null if you do not initialize it. So, using a local variable when creating your trigger will result in your global variable not pointing to it.
07-21-2007, 08:26 PM#8
darkwulfv
Except it does >.> Somehow, it works. I don't know why or how...
07-21-2007, 09:00 PM#9
Alexander244
Collapse JASS:
globals
  trigger gg_trg_Winning = null
endglobals

function test takes nothing returns nothing
  if gg_trg_Winning == null then
    call BJDebugMsg("Msg")
  endif
endfunction

function InitTrig_Winning takes nothing returns nothing
  local trigger t = CreateTrigger()
  call TriggerRegisterTimerEventPeriodic(t, 1.50)
  call TriggerAddAction(t,function Winning_Actions)
  set t = null
endfunction

So you are saying in the above example when the test function is called the message will not be displayed? because I can tell you it is...
Or are you just saying that that globals exists even if you don't define it in the trigger; if so, thats what everyone else has been saying.

The global variable for the trigger is set to null in the global block, and stays at null unless you set in to something.

Edited because: Missed out call.. doh.
07-21-2007, 09:20 PM#10
Silvenon
Ufff.......You got me scared there darkwulfv, tnx Alexander, now I know I'm not crazy. And one thing Alexander, it's call BJDebugMsg("Msg")
07-21-2007, 10:33 PM#11
darkwulfv
Well, I've never had to use anything involving triggers being used in other triggers before, but from what I can see, it works. Otherwise, my games would be ending 1.5 second in due to victory conditions firing off.

And all I did was refer to gg_trg_(trigger name), even though in the InitTrig block I created it on a local.