HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Simple Code Problem

05-24-2009, 07:49 AM#1
Linaze
Hello, I'm trying to create a trigger that registers when a unit enters a region, then a text should be displayed, the problem is, it isn't.
Collapse JASS:
globals
    rect TriggerRect = gg_rct_Test
    region TriggerRegion = CreateRegion()
    boolean FirstSlope = false
endglobals

function Actions takes nothing returns nothing
    call BJDebugMsg("Test")
endfunction

function Init takes nothing returns nothing
    local trigger Trig = CreateTrigger()
    call RegionAddRect(TriggerRegion,TriggerRect)
    call TriggerRegisterEnterRegion(Trig,TriggerRegion,null)
    call TriggerAddAction(Trig, function Actions)
endfunction
Any help why nothing happens when a unit enters the region would be appreciated, thanks.
05-24-2009, 09:24 AM#2
Fledermaus
The global rect TriggerRect is being assigned before gg_rct_Test has been created.

Also creating the region in the global block will cause the map to crash while loading.

Collapse JASS:
globals
    region TriggerRegion
    boolean FirstSlope = false
endglobals

function Actions takes nothing returns nothing
    call BJDebugMsg("Test")
endfunction

function Init takes nothing returns nothing
    local trigger Trig = CreateTrigger()
    set TriggerRegion = CreateRegion()
    call RegionAddRect(TriggerRegion, gg_rct_Test)
    call TriggerRegisterEnterRegion(Trig,TriggerRegion,null)
    call TriggerAddAction(Trig, function Actions)
endfunction