HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why does this run when not initially on?

01-19-2006, 05:11 AM#1
The_AwaKening
I have this periodic trigger set to initially off "intially on is unchecked" and trigger is greyed out. It is turned on via another trigger when a certain unit is killed. Any idea why this is running at map initialization?
Collapse JASS:
function Trig_Rax_Bonus_Actions takes nothing returns nothing
local integer i
local integer j=1
local integer k=0
    loop
        exitwhen j>3
        set i=(4*CountUnitsInGroup(udg_BarracksGroup[j])-2)
        loop
            exitwhen k>(3*j-1)
            if i>0 then
                call AdjustPlayerStateBJ( i, Player(k), PLAYER_STATE_RESOURCE_LUMBER )
                call AdjustPlayerStateBJ( i*10, Player(k), PLAYER_STATE_RESOURCE_GOLD )
            endif
            set k=k+1
        endloop
        set j=j+1
    endloop
endfunction

//===========================================================================
function InitTrig_Rax_Bonus takes nothing returns nothing
    set gg_trg_Rax_Bonus = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Rax_Bonus, 20.00 )
    call TriggerAddAction( gg_trg_Rax_Bonus, function Trig_Rax_Bonus_Actions )
endfunction
01-19-2006, 05:44 AM#2
qwertyui
2 possible things
1) it is possible that game regards all triggers, which names start with "Init" as the ones to run on map initialisation, regardless of whether they are disabled or not.

2) i believe there was a special function that flagged a trigger as disabled... i don't see it used in your code

Try changing trigger name and look up jass API about trigger disabling/enabling functions.
01-19-2006, 06:06 AM#3
The_AwaKening
I think I figured out how to do it. I changed my Init to this.
Collapse JASS:
function InitTrig_Rax_Bonus takes nothing returns nothing
    set gg_trg_Rax_Bonus = CreateTrigger(  )
    call DisableTrigger( gg_trg_Rax_Bonus )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Rax_Bonus, 20.00 )
    call TriggerAddAction( gg_trg_Rax_Bonus, function Trig_Rax_Bonus_Actions )
endfunction
Added in the line call DisableTrigger
01-19-2006, 06:46 AM#4
Earth-Fury
setting a trigger to initially off in GUI adds that line. eg: i jusyt picked some random stuff, turned it to initially off, and converted to JASS:

Collapse JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call DoNothing(  )
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Untitled_Trigger_001 )
    call TriggerRegisterGameStateEventTimeOfDay( gg_trg_Untitled_Trigger_001, EQUAL, 12 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
01-19-2006, 03:56 PM#5
Vexorian
yeah if the trigger is JASS seting it to off won't do anything