• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Little Question !

Status
Not open for further replies.
Level 9
Joined
Mar 9, 2010
Messages
272
Ive just started to use varibles and i understand what there used for but i want to know if the varible setting stays the same for example. I set the varible to be the item in slot one of a hero, then if i use the varible in a seperate trigger, is that varible still linked to that item. :wink:
 
Level 8
Joined
Jun 26, 2010
Messages
530
If it's a global, yes. All variables you set using the Variables Windows is a global. Locals can only be used with Jass. (except triggering unit, the only GUI local)
 
Level 4
Joined
Jul 23, 2008
Messages
99
Basically, variable saves the "address" of object. But there are two kind of var in WE : local and global. Local is equal to private, it means can be used in a function that it declared. And global is equal to public, it means can be used in any function.

Am I missed something?
 
Level 14
Joined
Aug 30, 2004
Messages
909
Ive just started to use varibles and i understand what there used for but i want to know if the varible setting stays the same for example. I set the varible to be the item in slot one of a hero, then if i use the varible in a seperate trigger, is that varible still linked to that item. :wink:

All the variables you set with the variable editor will be permanent unless you change them. It will always refer to that item.
 
Level 8
Joined
Jun 26, 2010
Messages
530
Default setting you mean "No Item"? AFAIK, there's no function that reset a variable to it's defaults, but since you know the default of your variable you can set your variable to it.
 
Level 30
Joined
Jan 31, 2010
Messages
3,551
Unfortunately, variables will leak if not reseted or removed.
They got re-wrote every time a new value is set for them.
Variables are useful, they can store values so the other triggers and loop triggers can efficiently use them without searching for that unit again.
Still, 70% of leaks are within usage of variables, and I highly recommend you to use them wisely, or to at least take a look at the http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/basic-memory-leaks-5889/
 
Status
Not open for further replies.
Top