• 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!

Question about Variable and Indexing

Status
Not open for further replies.
Level 7
Joined
Apr 18, 2010
Messages
104
Do you need to have a new variable name for each "MUI, Index, Caster" in each spells or is it possible to only have different "MUI" names for each spells but the "Caster" variables are the same..for example, on one spell the variables are Caster[MUI_1] and Target[MUI_1] (lets say that the dynamic indexing was done already) and on another spell its Caster[MUI_2] and Target[MUI_2]... will there be errors?? if not, then can i extend this thought to have a variable named MUI[x] so that there will be only 1 "MUI" named variable... basically the spells would have variables like "Caster[MUI[2]], Target[MUI[2]]" and the so on and so forth? Sorry for the bad grammar =D
 
in that tutorial the user made us of the variable SL_<insert something> and SL_Index and SL_Loop, what I am asking is, is it possible to use 1 single variable for all the would be casters in a map that has many spells? example a skill called omnislash would use a variable named "Spell_Caster" while another spell, ie, Void, would also use that same variable for storing its caster, they would basically differ in the variable in that array , (the one inside the []).

something like this
trigger 1:

Spell_Caster[MUI[1]] = Triggering unit (casted by unit A)

trigger 2:
Spell_Caster[MUI[2]] = Triggering unit (casted by unit B)

lets say that the two triggers are running at the same time but have different casters.

would the variables overlap each other? just curious so that i wont have to create tons of variables for every spell i make =D.
 
If I take your question literally, then you are asking if nesting array indices is possible.

Which I can answer with "yes":

Spell_Caster[SpellType[SpellInstance]] is possible.

However, this will not solve your problem. If MUI[1] and MUI[2] (which are terrible variable names btw, which is why I renamed them to SpellType[SpellInstance]) contain the same value, then Spell_Caster can and will be overwritten by the later instance allocated.


What you actually want is a two-dimensional array like:

Spell_Caster[SpellType][SpellInstance]


Unfortunately, this is only possible in vJass. But you can use Hashtables, which basicly work the same as two-dimensional arrays.
 
I meant global variables. The variables in the Variable Editor are globals. Plus, using local variables in GUI is a pain in the ass.

Local variables aren't even legal in GUI. The whole thing must be custom script. You can try variable shadowing, but it will be broken with an optimizer. You also get the wrong value when you try to reference it from a GUI if-block. Just not worth it at all.
 
I meant global variables. The variables in the Variable Editor are globals. Plus, using local variables in GUI is a pain in the ass.

So JNGP allows you to create global GUI variables without entering the variable editor or whatever that window is called?

I've been using JNGP wrong for 3 years if that's true...
 
So JNGP allows you to create global GUI variables without entering the variable editor or whatever that window is called?

I've been using JNGP wrong for 3 years if that's true...

I'll repeat:
You could always use JASS with JNGP so that you can declare your global variables within the script and not have to go in the bloody Variable Editor.
 
JASS:
globals
    integer myIntegerVariable = 12345
    string myStringVariable = "blablabla"
    trackable somethingThatIsImpossibleToMakeWithoutThisMethod
    handle somethingThatIsImpossibleToMakeWithoutThisMethod
    widget somethingThatIsImpossibleToMakeWithoutThisMethod
    agent somethingThatIsImpossibleToMakeWithoutThisMethod
endglobals

As you can see, there are quite a bit more variables that you can make with this method.
Also, no restrictions of name length :D
 
For something to be categorized as vJASS, it must be compiled by the JASSHelper.
Not much room for opinions.

However, you have plain JASS code in vJASS (normal functions, normal variables, normal stuff inside library tags or global tags) and struct JASS which is basically code that includes structs and/or access modifiers.
Only those two have any difference in how you write the code and some people are just more skilled in one of them.

Neither are bad but hard to use together.
 
Status
Not open for further replies.
Back
Top