| 02-17-2004, 11:14 AM | #1 |
Okay, this has been a huge pain in the ass since wc3 came out. Has anyone found a way to create a Variable of Variables. For example, say I have 12 variables for each of the twelve players called "booleanarray_1" "booleanarray_2" etc, which contain say for argument's sakes, 100 booleans in each. Has anyone found a way yet to just say like yep, SetVariable(BArrayVariables(PlayerNumber(1-100))). ? This would save me a shitload of time scripting. Thx in advance. |
| 02-17-2004, 11:22 AM | #2 |
Im not quite sure what you're asking, but it sounds like nested loops could do it? Otherwise you lost me =) |
| 02-17-2004, 11:31 AM | #3 |
Okay I havn't really dealt with JASS so I have no idea what nested loops are but the theory is this: Say you have twelve different variables, say Boolean Arrays, which can give a True or False answer for an infinate amount of Variables. Now lets say that each Variable is called "BooleanArray_P1" "BooleanArray_P2" etc, all the way up to "BooleanArray_P12". And what I am asking is if there is a Variable of Variables available. So if the Variable Variable was called "BArray_Variable" and was a Variable Array, and you set each value of it in relation to the BooleanArrays, for example; BArray_Variable(1) = BooleanArray_P1 But still keep BooleanArray_P1 as an array variable. So it would indeed look like this: Set ( BArray_Variable ( 1 ( 5 ( False ) ) ) ) Where BArray_Variable is the Variable Variable 1 relates to the Variable "BooleanArray_P1" 5 relates to Variable 5 of BooleanArray_P1 And False relates to BooleanArray_P1(5) being false. With me? :P |
| 02-17-2004, 11:41 AM | #4 |
I beleive the easyest way to do this uses game cach and can be found here |
| 02-17-2004, 10:49 PM | #5 |
That's confusing stuff and i'm usually pretty good with arrays/variable. Can you explain it in a different way perhaps? |
| 02-17-2004, 10:58 PM | #6 |
Me? |
| 02-17-2004, 11:00 PM | #7 |
Yeah and what do the variables/arrays represent in your map? |
| 02-17-2004, 11:15 PM | #8 |
Well I am going to use it for three things but for arguements sakes lets say a waypoint system like diablo II that I will be releasing for everyone to use as I never actually finish a map but make some nifty scripts. (Current count 210 unfinished maps *sigh*) I have made the waypoint system before but alas it would not work in conjunction with my real time system so I am trying to remake it more simplier so that it might be able to work with it. I have a Boolean Array that represents if a player has a waypoint active then its true, otherwise it is false. At the moment I have twelve of them, one for each player, named BooleanArray_P1 etc. Where 'P1' means Player1, Player2 etc. The problem I have though is when I create a dialog button I want to do. (Not the exact script but I have simplified it down for arguments sakes). For each Integer A do: If BooleanArray_P1(Integer A) is equal to true, then create a dialog button named (WP_Names(Integer A). But this problem means I have to copy and paste it twelve times for each player, so it ends up looking like this. If Owner of Triggering Unit equal to Player 1 then do If BooleanArray_P1(Integer A) is equal to true, then create a dialog button named (WP_Names(Integer A). If Owner of Triggering Unit equal to Player 2 then do If BooleanArray_P2(Integer A) is equal to true, then create a dialog button named (WP_Names(Integer A). But if I was able to somehow make a Variable of Variables I could write it at the following: If BArrayVariable(Player number of owner of triggering unit(Integer A)) is equal to true, then create a dialog button named (WP_Names(Integer A). Which means I would cut my triggers down by around 94%. So you know how you have Arrays of Integers, I want an Array of Variables, where I can actually call a variable as a variable to use. Btw I am on MSN if anyone cares to chat: [email protected] |
| 02-17-2004, 11:38 PM | #9 |
Ahh, so what you are refering to is simulating multi-dementional arrays? |
| 02-17-2004, 11:52 PM | #10 |
And I have like no idea what you just said :P Explain :) |
| 02-18-2004, 12:07 AM | #11 |
You could make a single boolean array with 1500 elements (100 per player, with 15 players counting neutrals) and then use VarName[PlayerNumber * 100 + Index] where playernumber is 0-14 and index is 0 to 99 |
| 02-18-2004, 12:08 AM | #12 |
A multi-dimensional array is somthing in programing with two indexes: name[index1][index two] Think of it as an array in an array. In your case it would be: Player[PlayerNum][ArrayRef] Stimulate with gamecahes. Theses a function/class for it somewhere. |
| 02-18-2004, 03:06 AM | #13 |
variables are very confusing i just use integers :p |
| 02-18-2004, 04:48 AM | #14 | |
Quote:
Hrmm, you beat me too it! damn you~! lol Yes, anyways that is what a multi-dimentional array is. Although Ive never been in a spot where they would be extreamly usefull. Howwever, on a map that has alot of custom spell that require, say, 6 integer varables per player, instead of useing 6 differnt arrays, you could use 1 multi dimentional one with a size of (12)(6). 12 , as in 12 players and the 6 integers for each. You see what I mean? |
| 02-18-2004, 06:18 AM | #15 |
It does sound like you want to simulate a multi-dimensional array. In my map, I have a 3-dimensional one to hold the units. THe first dimension being the race, the second the clsas, and the third the tier. Each dimension has 4 levels to it, making the total size of the array 64 (4*4*4). To make a more simple example, let's say you want just a 2-dimensional array. The first element's first dimension could be index 0. The first element's second dimension would then be 1. And the second element's first dimension would be index 2. And so on... Visually, you could think of it like this: Code:
1D 2D E1 0 1 E2 2 3 E3 4 5 E4 6 7 ... Where E1-2D would hold the value of the first element's second dimension, yadda yadda. I used values correlating to the index position of each value within a one-dimensional array. So by using the formula: 1Dindex = (2Dindex * 2) + D You can manipulate the values. For instance, if you want to get the first element's seond value (or second dimension), then substitute 0 (index of the first element) for 2Dindex and 1 (index of the second element) for D. 1Dindex = (0 * 2) + 1 so 1Dindex = 1 -- and as you can see, E1-2D also equals 1. If you want the first dimension of the 3rd element... 2Dindex = 2 D = 0 1Dindex = (2 * 2) + 0 So 1Dindex = 4 -- and E3-1D also equals 4. I hope I explained this all in a coherent manner, as it's a hard enough concept to grasp, let alone explain. For further help, you can view the source of a webpage I made earlier today (isn't it funny how weird stuff tends to coincide with itself) for a job interview thingy. The addy is http://www.raevanmorlock.com/samples/num1.html. In the page, I described the multiple dimensions as being "keys", but the same concept applies. Let me know if this needs further explanation. |
