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

[JASS] 2 Dimesional Arrays?

Status
Not open for further replies.
Level 2
Joined
Jan 19, 2008
Messages
7
Does JASS support arrays with 2 dimensions? I don't know much about JASS but I am learning, and I would like to convert a map project I am working on to JASS before it becomes huge. A 2d array would be perfect for the reputation system I am trying to make. (P1_Rep[13],P2_Rep[13],etc.... is a hassle)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
My_2d_Array[x+maxX*y]

For example, with an array of size [5][5], My_2d_Array[2+5*3] would access slot [2][3] (works with x and y = 0 to max-1, so in this case 0 to 4).

Or you could use dynamic arrays if you have JassNewGenPack and really want to.

JASS:
type myIntArray extends integer array [10]
globals
    myIntArray array test
endglobals
function TestFunction takes nothing returns nothing
    set test[0] = myIntArray.create() //you have to .create() and .destroy dynamic arrays
    set test[0][2] = 5
endfunction
 
Status
Not open for further replies.
Top