Tutorial Variable Introductory

Romek

Super Moderator
Reaction score
963
Indexes*

Let's say you have an Array of units called Units. In Unit[1], 1 is the index. Basically the integer you use to refer to the value.

So if I set size for a timer array to 10, it would go through indexes 1-10 (Timer[1],Timer[2]... etc) and sets them to CreateTimer()

Timer[11] through Timer[8191] would all be set to null (and you can't use anything higher than 8191). That means that you won't be able to use them in any way (unless you know JASS, of course).

Indexes isn't a real word. Indices is just the plural of Index.

Although that's true Darth, things such as integers can still be used from 0 - 8191 without any problems at all. Just set them to 0 when you start using it :)

But, You have got a point there. Timers, Dialogs and some other stuff can't be created in GUI, and have to be initialized.
 

Romek

Super Moderator
Reaction score
963
>_> I've always wondered, can you use negative indices? Like: Timer[-58]?
I doubt it.
It'll probably have the same effect as Variable[9994]. Always being null.

You could always use something like this though:
JASS:
function GetUnit takes integer index returns unit
  return UNITVAR[index + 1000]
endfunction

Then you'd have indexes from -1000 to 7191 :D
 

Romek

Super Moderator
Reaction score
963

Ryuu

I am back with Chocolate (:
Reaction score
64
Thanks for clearing things up. I myself learnt something about SIZE too ;)

Updated tutorial.
 

Romek

Super Moderator
Reaction score
963
will be set to 'null', and you can't use them in anyway, unless you know JASS

You can. The only ones you can't use are the types which can only be created by setting a default value to the variable.
Some I can name off the top of my head are:
  • Timers
  • Dialogs

And I think Multiboards and Leaderboards, but I'm not certain.

Things such as integers, reals, booleans, units, etc. You can use 0-8191 without any hassle, regardless of the array size you put in.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
You can. The only ones you can't use are the types which can only be created by setting a default value to the variable.
Some I can name off the top of my head are:
  • Timers
  • Dialogs

And I think Multiboards and Leaderboards, but I'm not certain.

Things such as integers, reals, booleans, units, etc. You can use 0-8191 without any hassle, regardless of the array size you put in.

You forgot about groups (depending on their usage) - if you're using Set Var = Units in... , defaulted array size doesn't matter, but if you're using it for Group - Add/Remove Unit, then the defaulted array size must be sufficient to encompass all the groups you will need

I guess you guys didn't see my first post in this thread. I explained it all in detail. The second post was just a more basic version/example, so the OP could understand it better.

The new edits are much better, nice work! (You also left off the [ /I ] tag at the end of the place where you gave us credit, though. ;))
 

Ryuu

I am back with Chocolate (:
Reaction score
64
> You can. The only ones you can't use are the types which can only be created by setting a default value to the variable.
Some I can name off the top of my head are:
  • Timers
  • Dialogs
(Romek)


Thanks. I'll update it.

> You also left off the [ /I ] tag at the end of the place where you gave us credit, though. (Darthfett)

Will change.

[DEL]Updating tutorial.. (2% done)[/DEL]
[DEL]Updating tutorial.. (12% done)[/DEL]
[DEL]Updating tutorial.. (27% done)[/DEL]
[DEL]Updating tutorial.. (34% done)[/DEL]
[DEL]Updating tutorial.. (56% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Update crashed. Reboot update? Y/N[/DEL]
[DEL]Y[/DEL]
[DEL]Updating tutorial.. (2% done)[/DEL]
[DEL]Updating tutorial.. (12% done)[/DEL]
[DEL]Updating tutorial.. (27% done)[/DEL]
[DEL]Updating tutorial.. (34% done)[/DEL]
[DEL]Updating tutorial.. (56% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Updating tutorial.. (84% done)[/DEL]
[DEL]Updating tutorial.. (99% done)[/DEL]
[DEL]Updating tutorial.. (100% done)[/DEL]
Tutorial updated.
 

Romek

Super Moderator
Reaction score
963
You might also want to add that most variables (Booleans, Units, Reals, Integers, etc) can be used up to index 8191 without setting the size.
So if you set the size to 0, the default value of the integer (for example) will be null, but you can easily set it using the set action.

Another thing, setting the array size to 8191 will probably make your Init trigger stop on that loop (Hitting the OP limit).
 

Ryuu

I am back with Chocolate (:
Reaction score
64
But too much information would probably make one beginner's head burst.
 

Romek

Super Moderator
Reaction score
963
But too much information would probably make one beginner's head burst.
Well they don't have to read it all at once.
It's related to variables, and as this is a variable tutorial, I believe it is necessary.
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Well okay. I've updated the tutorial again.

Well.. this thread is 3 pages already and I think it's time for me to get it approved. From what I understood from my tutorial, I realised I was only explaining what variables are in a very detailed way, but I'm not showing any good examples.

All I did was play around with the unit actions. It's 12.09 AM here and I'm going to sleep, but when I wake up tomorrow (or today, well, later, because its a new day already) I'm going to edit the tutorial and add in a new section, where I can provide examples (maybe spells) and I'll show screenshots of the spells to keep readers interested.

G'night.
 

Romek

Super Moderator
Reaction score
963
It's not up to you whether it's approved or not.
The content, usability, and originality can affect whether it's approved or not.

Originality is a problem here as there are quite a lot of variable tutorials, each of them explaining the same amount of stuff as this tutorial, or more (Locals?).
 

Ryuu

I am back with Chocolate (:
Reaction score
64
> I think it's time for me to get it approved.

Haven't slept yet, but I think you misunderstood :p

I actually meant that I have to get it approved not by me.

> The content, usability, and originality can effect whether it's approved or not.

I know it's not original. That's why I'm thinking of adding that new section.. and hopefully it's good :p
 

Xonora

New Member
Reaction score
3
> You can. The only ones you can't use are the types which can only be created by setting a default value to the variable.
Some I can name off the top of my head are:
  • Timers
  • Dialogs
(Romek)


Thanks. I'll update it.

> You also left off the [ /I ] tag at the end of the place where you gave us credit, though. (Darthfett)

Will change.

[DEL]Updating tutorial.. (2% done)[/DEL]
[DEL]Updating tutorial.. (12% done)[/DEL]
[DEL]Updating tutorial.. (27% done)[/DEL]
[DEL]Updating tutorial.. (34% done)[/DEL]
[DEL]Updating tutorial.. (56% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Update crashed. Reboot update? Y/N[/DEL]
[DEL]Y[/DEL]
[DEL]Updating tutorial.. (2% done)[/DEL]
[DEL]Updating tutorial.. (12% done)[/DEL]
[DEL]Updating tutorial.. (27% done)[/DEL]
[DEL]Updating tutorial.. (34% done)[/DEL]
[DEL]Updating tutorial.. (56% done)[/DEL]
[DEL]Updating tutorial.. (77% done)[/DEL]
[DEL]Updating tutorial.. (84% done)[/DEL]
[DEL]Updating tutorial.. (99% done)[/DEL]
[DEL]Updating tutorial.. (100% done)[/DEL]
Tutorial updated.

at this, i rofl'ed. and THANK YOU SO MUCH. I am beginning to understand wat variables are in the first place now. now to work on my blink strike....

so to clarify, if i just spam dummy units for a shield effect i will get a serious lag ltr in the game? even if the unit's model animation expires after it appears?
 

Ryuu

I am back with Chocolate (:
Reaction score
64
If you remove the leaks, I think it should be fine.
However, if you spawn 1000 dummy units at once per every 0.03 seconds, even if you remove the dummies and remove the leaks, I think you'll get a serious lag.
 

staticfrog

New Member
Reaction score
1
I'm having a problem at this part
Q: So how do we travel in time?
A: You must learn how to duplicate units first. After the fourth action, add a 60 second Wait and then repeat the first three actions. Now test the map.
It's not working for me, when I test the map it just shows the starting point, the red buliding, and the default workers it comes with, then it says victory right when the game starts, help=/

ooh, didn't know you could do this ,well this is what it looks likexD
Trigger:
  • Create Unit
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set TestPoint = (Center of (Playable map area))
      • Unit - Create 1 Footman for Neutral Passive at TestPoint facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_TestPoint )
      • Set TestUnit = (Last created unit)
      • Wait 60.00 seconds
      • Set TestPoint = (Center of (Playable map area))
      • Unit - Create 1 Footman for Neutral Passive at TestPoint facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_TestPoint )


If it helps, it's in the folder intialization under the trigger melee initiaionza
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top