Tutorial Local variables in GUI

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Introduction

Have you ever made a spell, what uses lots of waits or loops, involving several dummy units? Have you ever wondered why it messes up and is only usable by one hero per a map? If yes, this tutorial will explain, why this is like so and show possible solutions to your porblem.

Before we can get started, I will explain a few acronyms and words, that I will be using later to explain further details.

MUI (Multi Unit Instanceable)

Generally associated with spells. It means more than one unit can cast a trigger enchanced spell at the same time, without interfering the other unit. (without interfereing the triggers actions)

Global variable


A variable, which holds information (depends on the type of the variable), what can be used in all functions.

Local variable

A variable, which holds information, but it can only be used in the function it was created in. (A local variable, however, can be used in other functions aswell, while still being local, with the help of Kattana’s Handle Variables or with Vexorians Caster System.)

(Kattana’s Handle Variables
http://www.wc3jass.com/viewtopic.php?t=224

Vexorians Caster System
http://www.wc3campaigns.net/showthread.php?t=80534)

Lets get started!


The easiest way to make a spell mui, is using ‚triggering unit’ instead of casting unit. Every time a trigger is run, it has it’s own triggering unit. Besides, casting unit unstable, it tends to get lost after waits.

Example #1

exmaple1.gif


An ability is cast and the casting unit should get a new ability for 30 seconds. But what will happen, if another unit casts the ability? The casting unit gets overridden. Besides, casting unit gets lost after waits, especially after long one. The final result would be that the ability never gets removed.

How to solve it?

exmaple1_a.gif


Replace the casting unit with triggering unit, because casting unit is actually the triggering unit.

The prior – declaring local variables in GUI.


But, what to do, if I have more than one unit used by a spell, which needs to be local?

The solution is tricking the World Editor to think a global variable (which holds the value of your unit) is a local one.

How can I do that?

You have to use the ‚custom script’ action.

Remember:


Local variables are always declared in the beginning of a function.

Every local variable has to be nulled in the end of a function, execpt a real, an integer, a boolean or a string local variable.

Global variables have udg_ prefixes.

The syntax for declaring local variables.
Custom Script : local variable type variable name

Example #2

How to declare a local global variable in GUI.

Lets say you need the TmpUnit and TmpPoint to be local. The declaration would be following.

example2.gif


As you can see, the point variable is called location variable in JASS. There are more differences. Here is the list of the most used variable types. (JASS is case-sensitive)

I shall remind the syntax one more time.

local variable type variable name

World Editor variable type name======>Real variable type name

(Why in the world I cannot use TAB?)

Boolean=======================>boolean
Destructible====================>destructable
Floating Text===================>texttag
Integer=======================>integer
Item=========================>item
Player========================>player
Player Group===================>force
Point=========================>location
Real=========================>real
Region=======================>rect
Sound=======================>sound
Special Effect=================>effect
Lightning=====================>lightning
String=======================>string
Terrain Deformation=============>terraindeformation
Timer=======================>timer
Timer Window=================>timerdialog
Ubersplat====================>ubersplat
Unit========================>unit
Unit Group===================>group

To pull the loose ends together, I have to mention that one cannot use local global variables in unit groups, if/then/else’s and in ‘for each integer a do multiple action’ loops, because blizzard programmed them to be separate functions and local variables cannot be transferred between functions. (Without the help of the above-mentioned systems, of course. But that is JASS playground.)
Also only one variable per type can be overriden and local arrays don't override global ones.

Have fun experimenting with local global variables!

PS: Please correct me, if I am wrong somewhere or if I have spelling mistakes. Feedback is always appriciated.
 

Master

Thou shall be helped by...The Black Adder!
Reaction score
72
Very nice (I read 50% of it, though).
Do you know what is funny? this was about to be my next tutorial...now I have to move on :p
 
W

wahoyaho

Guest
how did you set TmpPoint?

I can't see my local variables in the variables list
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
TmpPoint and TmpUnit are actually global variables, what you have to create in the variable editor. The custom script is needed to trick the Editor into thinking they are local variables.
 

The Big S

New Member
Reaction score
6
Just create a new variable point, and call it TmpPoint


If you already did that, then it should be there =/

EDIT: Hehe, sorry, didn't see your post before posting Andrew
 
Reaction score
456
I prefer to use JASS or GUI alone, not mixed. Altough a nice looking :p
You know what's funny... I'm writing with WII :p

Anyway, you didn't mention ubersplat in the list of different types of variables. (this is kinda slow way to write in forums..)
 

SFilip

Gone but not forgotten
Reaction score
634
Well if you make a local variable with the same name as some global it will override it in the function it was declared in.

This has two limits though:
-only one variable per type can be overriden - you can't, for example, have two "fake" locals of type unit
-local arrays don't override global ones from some reason
 

SFilip

Gone but not forgotten
Reaction score
634
Oh and almost forgot...
The "can be used in other functions aswell" with the handle variables and all can be quite misguiding. People usually don't know what a function is. If they do then they might just go for implementing local handle variables (or the caster system) somehow, somewhere thinking that this would make them able to use "fake" locals inside if..then..else and player/unit group enumerations. And, well, if they know that is not the case...then why the hell are they still using GUI? :p
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
To pull the loose ends together, I have to mention that one cannot use local global variables in unit groups, if/then/else’s and in ‘for each integer a do multiple action’ loops, because blizzard programmed them to be separate functions and local variables cannot be transferred between functions. (Without the help of the above-mentioned systems, of course. But that is JASS playground.)

I know. Global locals are for lazy people or people, who do not wish to learn JASS.:p
 

ayumilove

Youtube account suspended! youtube.com/ayumilove8
Reaction score
110
this tutorial not so useful, try teaching us how to use katana system or vexorian system, its much better compare to the one you have written up there.

in this way, more people will be introduce to their powerful system, and more people would use it, instead of relying the local variable in gui.

to me, i find it rather useless to have local variable with gui.

global is much better <3
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
>this tutorial not so useful, try teaching us how to use katana system or vexorian system, its much better compare to the one you have written up there.
>in this way, more people will be introduce to their powerful system, and more people would use it, instead of relying the local variable in gui.

Now, there is a problem. Handle Variable isn't local variables or global variables, it's a completely different thing :)
It's more of 'object variables', an object that owns it's own variables and are not sharing them with anything else.

>global is much better
Well, I understand that you aren't that serious with this :)
However, just for those who doesn't know. Globals aren't better than locals, and locals aren't better than globals. They are just two different tools for a programmer to use, using the wrong tool is bad but that doesn't mean that the tool is worthless.
 

Chocobo

White-Flower
Reaction score
409
Boolean=======================>boolean
Destructible====================>destructable
Floating Text===================>texttag
Integer=======================>integer
Item=========================>item
Player========================>player
Player Group===================>force
Point=========================>location
Real=========================>real
Region=======================>rect
Sound=======================>sound
Special Effect=================>effect
Lightning=====================>lightning
String=======================>string
Terrain Deformation=============>terraindeformation
Timer=======================>timer
Timer Window=================>timerdialog
Ubersplat====================>ubersplat
Unit========================>unit
Unit Group===================>group

Isn't it a bit too big..? You can simply put handle to all.


for each integer a do multiple action’ loops

Wrong. But you must use local loops to avoid Integer A/B overriding.


PS: Please correct me, if I am wrong somewhere or if I have spelling mistakes. Feedback is always appriciated.

Yes you did a weird one:

(Kattana’s Handle Variables


Maybe removed the sign?
 
M

Mythic Fr0st

Guest
hmm

Looks good, only read about 2% of it, but the big images of the triggers look good! lol (im not in a reading mood)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
this tutorial not so useful, try teaching us how to use katana system or vexorian system, its much better compare to the one you have written up there.

That assumes one knows JASS above medium level, if reading a tutorial about handle variables or the caster system.
 

exge

New Member
Reaction score
15
this tutorial not so useful, try teaching us how to use katana system or vexorian system, its much better compare to the one you have written up there.

in this way, more people will be introduce to their powerful system, and more people would use it, instead of relying the local variable in gui.

to me, i find it rather useless to have local variable with gui.

global is much better <3

lol true
 

Cohadar

master of fugue
Reaction score
209
LoL those systems are outdated.

Kattana, Vexorian and Cohadar are using structs now :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top