HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Variables inside Variables?

11-24-2004, 06:47 PM#1
oNdizZ
I know that i have seen threads about this before, but i can't find them, so therefore i've made this thread.

hum, what i mean with the title is...

Example:
a spell, where i use a loop for special effects, i now want 200 special effects for this spell, and later i need to take them away, so i set them into variables (set PsyWaveEffect[Integer A] = last created special effect) like that...

but then, this spell is for a multiplayer map, so i need it for everyplayer, is there anyway of doing it like this?

Set PsyWaveEffect[(playernumber) of (owner of (casting unit))][Integer A] = last created special effect

is it possible?
if its not, anyone know a alternate way of doing it?

thx on advance
11-24-2004, 07:18 PM#2
Guest
That should work fine as far as I can see.
11-24-2004, 07:20 PM#3
oNdizZ
well how?
an example plz :)
11-24-2004, 07:23 PM#4
Guest
I'm not sure exactly what your trying to do.
11-24-2004, 07:28 PM#5
AIAndy
While that solution works (look for threads about how to put 2d arrays into 1d arrays), it might be better if you learn about local variables and use them instead.
11-24-2004, 07:36 PM#6
oNdizZ
well, local and global variables sticks to the jass-world, i stick to the GUI-world :) even if i really would like to learn jass, i have no idea where to start at all.
11-24-2004, 08:54 PM#7
AFB-DieHard
I know JASS a little, it is easy to learn if you know another programming language. If you don't do, just read a tutorial about it. If you know the syntax you can learn a lot by converting GUI triggers to JASS and look what they look like. (but keep in mind GUI converted to JASS is not very beatiful and hard to read, but you can see what the commands look like)
11-25-2004, 12:18 AM#8
th15
The idea behind 2d arrays is to use one or two digits as an index while the rest of the digits contain the actual reference to the variable.

If your case, what you would do is use the arithmetic functions to assign each SFX to a variable + (player number x 1000).

That way Variable[1001] to [1999] refers to player 1's variables.

So, this: Set PsyWaveEffect[(playernumber) of (owner of (casting unit))][Integer A] = last created special effect

would look more like this: Set PsyWaveEffect[((playernumber) of (owner of (casting unit))x1000) + Integer A] = last created special effect
11-25-2004, 03:47 PM#9
oNdizZ
th15, i know of that, the problem is that i have 200 special effects for each player, with 8 player totally
that gives me a need of a 8200 large variablearray

and the max number is something under, like 81xx

so... :S
11-25-2004, 04:30 PM#10
AFB-DieHard
then why not switch it so you have 0011-2001 for player 1, 0012-2002 for player 2, and so on.(when you have 200 special effects)

But I think (memory-wise) the best solution is to use the index
[special effect*7+player]
Where player is 0....7 not 1....8, and special effect too.
11-25-2004, 04:39 PM#11
th15
Well you don't have to use "player number x 1000". That just made it easier.

You can use "((player number x 200) + integer A) + player number)". That way index 201 to 401 refers to P1's stuff, index 402 to 602 refers to P2's stuff and so on. It'll be a little difficult to retrieve the player number of a given variable though, so make sure you work in the other direction.
11-25-2004, 04:45 PM#12
oNdizZ
hmm, now why haven't i thinked about that before? :D
thx, its solved now...