| 03-03-2005, 10:26 PM | #1 |
How can I use multi dimensional arrays in WE? I've tryed to changer the number value in the variables but nothings happen? |
| 03-03-2005, 11:20 PM | #2 |
just use a 1 dimensional array with size = x*y each cell has his number. Take this example with a 5x5 matrix. Code:
[01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] Create a single array of size 25 and move on it by X for columns and by (Y-1)*5. Size of Matrix = Size_X*Size_Y Move to X = X Move to Y = (Y-1) * Size_X Ex. 1 You want to find the item in column 4 row 3 Code:
[01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [color=red][14][/color] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] Ex. 2 You want to find the item in column 1 row 5 Code:
[01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [color=red][21][/color] [22] [23] [24] [25] Ex. 3 You want to find the item in column 5 row 1 Code:
[01] [02] [03] [04] [color=red][05][/color] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] |
| 03-04-2005, 12:06 AM | #3 |
or... an ezer way... if ur wanting 2 make like a boolean for all ur players or something so that each player has like 15 slots all in 1 variable, use: Code:
variable[((player number of player u want) * 100) + slot number] that way, slot 507 would b player 5s slot number 7, very simple and effective. |
| 03-04-2005, 04:43 AM | #4 | |
Quote:
you do realize you just repeated what the first guy said, basically that theres no native ways to represent matricies -- only to simulate them with functions and an array + thats a little inefficient use of memory since its gonna reserve a lot of space that won't be used at all, why not Value = (player number) * 15 + index |
| 03-05-2005, 12:01 AM | #5 | |
Quote:
About his spam, I think he doesn't read the post because it was too long for him ^_^ he is wrong about the 100, he didn't read or didn't understand ^_^ this is [x*Sy+y] where Sy is the size of the y dimension So 100 is supposed to be the Sy (and of course : 0<=x<Sx and 0<=y<Sy) By the way this thread has the best explanantion. There is already about 3 thread about this subjects ^_^ With this methode you can have array with X dimension because you can do 2D -> 1D So 3D=2D+1D->1D+1D=2D->1D and so on... Will be in the JASS FAQ |
| 03-06-2005, 04:24 AM | #6 |
so what is the number field in varibles then? |
