[JASS] 2 Dimesional Arrays?

Status
Not open for further replies.

Bastion

B

Bastion

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)
 
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
 
Thank you for the help, I haven't had a chance to try it yet due to another map project but I will use it soon.
 
Status
Not open for further replies.
Back
Top