• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[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