• 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.

Arrays as Parameters

Status
Not open for further replies.
Level 3
Joined
Dec 30, 2011
Messages
54
Hey guys!
Is possible to use arrays as parameters?
example:
JASS:
globals
unit array x
endglobals

function b takes unit array p returns nothing
. . .
endfunction

function a takes nothing returns nothing
. . .
call b(x)
. . .
endfunction

or something like this
 
x is just array name, while x[y] can be variable you need.
What you ask is almost same like this:

call B(integer)

I guess you ask because of problems of this type:
JASS:
globals
    unit array X
endglobals

function b takes unit array p returns nothing
    . . .
endfunction

function a takes nothing returns nothing
    local unit x = X[GetUnitTypeId(GetTriggerUnit())]
    . . .
    call b(x)
    . . .
endfunction
because local unit x = X[GetUnitTypeId(GetTriggerUnit())] won't work (array max limit is 8192 while unit ID >> 8192)

You can use hashtables or other units related values (custom, point), actually you have more than few ways to do this.
 
Status
Not open for further replies.
Top