HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

BUG: converting a trigger to JASS then un-checking "Initially On"

01-12-2007, 02:08 PM#1
CaptainPicard
Did anyone know about this bug? I created a trigger with a 0.04 second periodic event, then converted it to custom text to serve as a "backstage", something that also runs precisely so I can manage external events with Anitarf and iNfraNe's cinematic system, without having to create loads of extra triggers. Doing so produces this code:

Collapse JASS:
function Trig_TEST_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_TEST takes nothing returns nothing
    set gg_trg_TEST = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_TEST, 2 )
    call TriggerAddAction( gg_trg_TEST, function Trig_TEST_Actions )
endfunction

THEN, I remembered that I don't want this initially on, so I unchecked that option in the GUI. Oops. The custom JASS script remains the same, but I didn't notice this. If you un-check "Initially On" BEFORE you convert to custom text, the GUI puts in this handy little line:

Collapse JASS:
function Trig_TEST_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_TEST takes nothing returns nothing
    set gg_trg_TEST = CreateTrigger(  )
    call DisableTrigger( gg_trg_TEST )
    call TriggerRegisterTimerEventPeriodic( gg_trg_TEST, 2 )
    call TriggerAddAction( gg_trg_TEST, function Trig_TEST_Actions )
endfunction

And that makes quite a difference. When I tried to run my map with a bunch of custom script written in the original trigger, I found that it executed precisely once, at map initialization or thereabouts, and then never ran again--as if it didn't even exist. Fortunately I could simply copy my custom text to a different trigger and move on.

I use the DisableTrigger( ) function in my own JASS, and it's obvious what's going on. Just remember, though--while the GUI is smart enough to change the titles of triggers in the
Collapse JASS:
function Trig_<name>_Actions
and
Collapse JASS:
InitTrig_<name>
places after you've converted to custom text, it's not smart enough to turn something initially off.

Capt. Picard

Edit: colorized text reformatted to fix typo
01-12-2007, 02:21 PM#2
Daelin
TriggerRegisterEventTimer period must be on a new line.

Collapse JASS:
function InitTrig_TEST takes nothing returns nothing
    set gg_trg_TEST = CreateTrigger(  )
    call DisableTrigger( gg_trg_TEST )
    call TriggerRegisterTimerEventPeriodic( gg_trg_TEST, 2 )
    call TriggerAddAction( gg_trg_TEST, function Trig_TEST_Actions )
endfunction

~Daelin
01-12-2007, 02:31 PM#3
Vexorian
I think it was a typo when trying to colorize the code.

And yes, we knew, Turn Off/On only works for GUI that's how it is removed when changing to custom text. You can end having a grayed out trigger that is turned on, kind of cool anyways
01-12-2007, 02:59 PM#4
Alevice
I usually just comment out the register event function when I want to "disable" it (assuming I don't call it somehwere else, though :P).
01-12-2007, 03:16 PM#5
Rising_Dusk
I just, you know, disable the trigger.
01-12-2007, 04:16 PM#6
CaptainPicard
The colorized text did indeed give me a typo. Fixed.

Yes, but I want the trigger to be initially of, to be turned on and then run peridoically later in the map. I was just surprised that the GUI could make an error like this, that's all.