HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

limitations with TriggerRegisterUnitInRange()?

05-08-2007, 08:32 AM#1
substance
I have this in a trigger that runs on map initialization:
Collapse JASS:
set udg_BlueFlagUnit = CreateUnit(Player(6),'n00W',bx,by,bj_UNIT_FACING)

Then my second trigger :
Collapse JASS:
function Trig_Flag_Radius_l_BLUE_Actions takes nothing returns nothing
call BJDebugMsg("running actions")
endfunction

//===========================================================================
function InitTrig_Flag_Radius_l_BLUE takes nothing returns nothing
    set gg_trg_Flag_Radius_l_BLUE = CreateTrigger(  )
    call TriggerRegisterUnitInRange(gg_trg_Flag_Radius_l_BLUE,udg_BlueFlagUnit,300,null)
    call TriggerAddAction( gg_trg_Flag_Radius_l_BLUE, function Trig_Flag_Radius_l_BLUE_Actions )
endfunction

Now, the unit is created (i can see it) but the second trigger doesnt work. I think the problem is that the second trigger is being initialized before udg_BlueFlagUnit is given a value.

I assume this because when I used the vJass method of declaring the global it told me that BlueFlagUnit wasnt initialized. And yes, the first trigger is above the second.. I even tried putting the createunit line in a function in the map header.
05-08-2007, 08:43 AM#2
Earth-Fury
If you're using vJass, use a library with an initializer.
Collapse JASS:
library mylib initializer myfunc
    function myfunc takes nothing returns nothing
        //init variables here
    endfunction
endlibrary

initializers are called before InitTrig_* functions.
05-08-2007, 08:59 AM#3
Thunder_Eye
putting
Collapse JASS:
set udg_BlueFlagUnit = CreateUnit(Player(6),'n00W',bx,by,bj_UNIT_FACING)
in the
Collapse JASS:
function InitTrig_Flag_Radius_l_BLUE takes nothing returns nothing
should work aswell.
05-08-2007, 09:21 AM#4
substance
Quote:
Originally Posted by Thunder_Eye
putting
Collapse JASS:
set udg_BlueFlagUnit = CreateUnit(Player(6),'n00W',bx,by,bj_UNIT_FACING)
in the
Collapse JASS:
function InitTrig_Flag_Radius_l_BLUE takes nothing returns nothing
should work aswell.

Oh wow, I didnt even think to do that.

Well, both methods work, thanks guys!