• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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