• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
Top