Tutorial Variable Introductory

Romek

Super Moderator
Reaction score
964
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
964
>_> 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
964

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
964
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
964
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
964
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
964
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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top