• 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] is posible to create a Matrix?

Status
Not open for further replies.
Level 11
Joined
Dec 31, 2007
Messages
780
Hello guys...

i want to know if i can create a Matrix in WE

i want to have 5 different values (which would be an array) for every player (that would be another array) and want to use them in a loop

something like

"player[1] [1]" value would be 5 and "player[1] [2]" would be another value

obs: I only do things in gui... but if there is a way to do this i think i can handle the custom scripts ^^
 
Level 11
Joined
Dec 31, 2007
Messages
780
well... i need to save 5 integers per player and use them in a loop... and i dont want to ask "if triggering player == to player 1 then bla bla"

thats why i ask if there is a way to create a doble array (matrix i think)
 
Level 3
Joined
Dec 20, 2007
Messages
44
If you're using vJass (like the newgen pack) you can simply add a trigger, convert it to custom text, and then modify it to just say something like:

JASS:
globals
      integer array udg_Player[12][12]
endglobals

which would create a 12x12 matrix, then to use it the simplest way in GUI (though not the most efficient) would be to use a variable, I'll call it TempInt, and the custom script:

to set a value
JASS:
set udg_Player[x][y] = udg_TempInt

to get a value
JASS:
set udg_TempInt = udg_Player[x][y]

x and y can either be numbers or variables (if you're using a For Integer A loop, you can use bj_forLoopAIndex). TempInt would be an integer variable defined in the trigger window.

If you don't have vJass, let me know how many matrices you're going to want to use.
 
Level 9
Joined
Jan 14, 2008
Messages
366
oh... you actually ment a matrix like those from math lessons... for some reason i tought you were actually talking about a matrix as a virtual parallel kind of world in a map of warcraft, in wich you could interact by chat commands. something like in the movie "matrix".

._. sry lol
 
Level 11
Joined
Dec 31, 2007
Messages
780
hahahha

no i mean a "2d array" xD

@yixx no i dont (and dont know if you can) but follow the link that josemite posted and there is a guy that will tell you how to use 1d arrays as 2d with an small formula that is (((row number-1)*max columns)+column)... its kinda silly but usefull (the array has the size of rows*columns)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Yes they are possiable, you simply.

[X*Ymax+Y]

Remember that the max size is 8192 for an array.

Eg [X*10+Y] allows you to use X in the range of 0 to 819 and Y in the range of 0 to 9.
This method is very fast and for numerous opperations can be optimized further by eliminating constants for that part of a function (eg if you use the same X you can set a local integer to X*10 and then just use that integer+Y).

Using the same method you could also get up to 8192 deminsion arrays, but the more demensions start to make it usless as they have very small bounds.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Ok, but i tried this in Jass:
JASS:
globals
   real array udg_AF_Factor [17][17]
endglobals
 
function reals takes nothing returns nothing
   set udg_AF_Factor[1][1] = 1.
//and a whole lot more
endfunction

I tried, and it gave no errors! So, is this possible?

EDIT: Ok, why is this failing? It gives no errors when i click 'Enable' and again, but when saving, it does!
JASS:
globals
   real array udg_AF_Factor [17] [17]
endglobals
function Trig_Factor_Damage_Integers_Actions takes nothing returns nothing
    local integer i = 1
    local integer ii = 1
    loop
        exitwhen i > 17
        loop
            exitwhen ii > 17
            set udg_AF_Factor[i][ii] = SquareRoot(2.00)
            set ii = ii + 1
        endloop
        set ii = 1
        set i = i + 1
    endloop
    set udg_AF_Factor[1][13] = 1.
    set udg_AF_Factor[1][14] = 0.
    set udg_AF_Factor[1][17] = 1.
    set udg_AF_Factor[2][2] = 1.
    set udg_AF_Factor[2][3] = 1.
    set udg_AF_Factor[2][5] = 2.
    set udg_AF_Factor[2][6] = 2.
    set udg_AF_Factor[2][12] = 2.
    set udg_AF_Factor[2][13] = 1.
    set udg_AF_Factor[2][15] = 1.
    set udg_AF_Factor[2][17] = 2.
    set udg_AF_Factor[3][2] = 2.
    set udg_AF_Factor[3][3] = 1.
    set udg_AF_Factor[3][5] = 1.
    set udg_AF_Factor[3][9] = 2.
    set udg_AF_Factor[3][13] = 2.
    set udg_AF_Factor[3][15] = 1.
    set udg_AF_Factor[4][3] = 2.
    set udg_AF_Factor[4][4] = 1.
    set udg_AF_Factor[4][5] = 1.
    set udg_AF_Factor[4][9] = 0.
    set udg_AF_Factor[4][10] = 2.
    set udg_AF_Factor[4][15] = 1.
    set udg_AF_Factor[5][2] = 1.
    set udg_AF_Factor[5][3] = 2.
    set udg_AF_Factor[5][5] = 1.
    set udg_AF_Factor[5][8] = 1.
    set udg_AF_Factor[5][9] = 2.
    set udg_AF_Factor[5][10] = 1.
    set udg_AF_Factor[5][12] = 1.
    set udg_AF_Factor[5][13] = 2.
    set udg_AF_Factor[5][15] = 1.
    set udg_AF_Factor[5][17] = 1.
    set udg_AF_Factor[6][2] = 1.
    set udg_AF_Factor[6][3] = 1.
    set udg_AF_Factor[6][5] = 2.
    set udg_AF_Factor[6][6] = 1.
    set udg_AF_Factor[6][9] = 2.
    set udg_AF_Factor[6][10] = 2.
    set udg_AF_Factor[6][15] = 2.
    set udg_AF_Factor[6][17] = 1.
    set udg_AF_Factor[7][1] = 2.
    set udg_AF_Factor[7][6] = 2.
    set udg_AF_Factor[7][8] = 1.
    set udg_AF_Factor[7][10] = 1.
    set udg_AF_Factor[7][11] = 1.
    set udg_AF_Factor[7][12] = 1.
    set udg_AF_Factor[7][13] = 2.
    set udg_AF_Factor[7][14] = 0.
    set udg_AF_Factor[7][16] = 2.
    set udg_AF_Factor[7][17] = 2.
    set udg_AF_Factor[8][5] = 2.
    set udg_AF_Factor[8][8] = 1.
    set udg_AF_Factor[8][9] = 1.
    set udg_AF_Factor[8][13] = 1.
    set udg_AF_Factor[8][14] = 1.
    set udg_AF_Factor[8][17] = 0.
    set udg_AF_Factor[9][2] = 2.
    set udg_AF_Factor[9][4] = 2.
    set udg_AF_Factor[9][5] = 1.
    set udg_AF_Factor[9][8] = 2.
    set udg_AF_Factor[9][10] = 0.
    set udg_AF_Factor[9][12] = 1.
    set udg_AF_Factor[9][13] = 2.
    set udg_AF_Factor[9][17] = 2.
    set udg_AF_Factor[10][4] = 1.
    set udg_AF_Factor[10][5] = 2.
    set udg_AF_Factor[10][7] = 2.
    set udg_AF_Factor[10][12] = 2.
    set udg_AF_Factor[10][13] = 1.
    set udg_AF_Factor[10][17] = 1.
    set udg_AF_Factor[11][7] = 2.
    set udg_AF_Factor[11][8] = 2.
    set udg_AF_Factor[11][11] = 1.
    set udg_AF_Factor[11][16] = 0.
    set udg_AF_Factor[11][17] = 1.
    set udg_AF_Factor[12][2] = 1.
    set udg_AF_Factor[12][5] = 2.
    set udg_AF_Factor[12][7] = 1.
    set udg_AF_Factor[12][8] = 1.
    set udg_AF_Factor[12][10] = 1.
    set udg_AF_Factor[12][11] = 2.
    set udg_AF_Factor[12][14] = 1.
    set udg_AF_Factor[12][16] = 2.
    set udg_AF_Factor[12][17] = 1.
    set udg_AF_Factor[13][2] = 2.
    set udg_AF_Factor[13][6] = 2.
    set udg_AF_Factor[13][7] = 1.
    set udg_AF_Factor[13][9] = 1.
    set udg_AF_Factor[13][10] = 2.
    set udg_AF_Factor[13][12] = 2.
    set udg_AF_Factor[13][17] = 1.
    set udg_AF_Factor[14][1] = 0.
    set udg_AF_Factor[14]11] = 2.
    set udg_AF_Factor[14][14] = 2.
    set udg_AF_Factor[14][16] = 1.
    set udg_AF_Factor[14][17] = 1.
    set udg_AF_Factor[15][15] = 2.
    set udg_AF_Factor[15][17] = 1.
    set udg_AF_Factor[16][7] = 1.
    set udg_AF_Factor[16][11] = 2.
    set udg_AF_Factor[16][14] = 2.
    set udg_AF_Factor[16][16] = 1.
    set udg_AF_Factor[16][17] = 1.
    set udg_AF_Factor[17][2] = 1.  
    set udg_AF_Factor[17][3] = 1.
    set udg_AF_Factor[17][4] = 1.
    set udg_AF_Factor[17][6] = 2.
    set udg_AF_Factor[17][13] = 2.
    set udg_AF_Factor[17][17] = 1.
endfunction
 
Last edited:
Status
Not open for further replies.
Top