[Solved] A simple JASS question.

Status
Not open for further replies.
Level 9
Joined
Dec 15, 2009
Messages
625
JASS:
function func_2 takes nothing returns rect 
local rect r = Rect(100,100,100,100)
return r
endfunction

How can I use this rect in further functions?
 
JASS:
globals
    rect NightbladeRect = Rect(0, 0, 100, 100)
endglobals

function AnyRandomFunction takes nothing returns nothing
    local region r = CreateRegion() 
    call RegionAddRect(r, NightbladeRect)
    if IsUnitInRegion(r, GetTriggerUnit()) then // this is just random there is no triggering unit
        call RemoveRegion(r) 
        call Player(16)
    endif
    call RemoveRegion(r)
    set r = null
endfunction

The point is that if you save your rect as a global, you can reference it anywhere. If you've got it as a function, then you're probably going to want to do this rather than creating rect objects over and over again.

Edit//

Oh, didn't see it marked as solved.
 
Status
Not open for further replies.
Back
Top