• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Question about variables

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2014
Messages
152
If you have a point variable for a certain spell(triggered), let's say it's variable name is CasterPoint. Can I use the variable "CasterPoint" for another triggered spell? or will that cause bugs?
 
Level 18
Joined
May 11, 2012
Messages
2,103
You can use same variables if the spell or action is instant without bugging up.
I usually call variables for instant actions or triggers "TempInt" or "TempPoint" or "TempUnitGRoup" or "TempReal" if you understand.
But for spells, I myself, create a variable that'll be used just for that spell.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
You should not because you do not know how the implementation will blow up. Even if it is "instant", there may be interrupts. You should avoid global variables when possible anyway because then your code will be less instanceable, less recursion-capable. It's also better for debugging to separate it.
 
Level 5
Joined
Jan 23, 2014
Messages
152
You should not because you do not know how the implementation will blow up. Even if it is "instant", there may be interrupts. You should avoid global variables when possible anyway because then your code will be less instanceable, less recursion-capable. It's also better for debugging to separate it.

If I use different variables for every spell, would that increase the map size? Because I plan to make a lot of spells for my map and I'm trying to save up space
 
Level 5
Joined
Jan 23, 2014
Messages
152
@Rheiko: Are you talking about arrays? sorry I'm new to the WE. anyway the variables I'm having trouble with are the points (Position of casting unit to be exact). I have a lot of spells that will be referencing to the pos. of the casting unit.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Of course each new declaration increases the map size. But that's marginal in comparison to other assets of the map like imports.

Since you asked for it, I just looked up how much the globals block in my current project weights.

1.483mb for 25689 variables with a compression ratio of 15% -> 222.45kb -> 8.6 bytes per variable on average

and that's before wc3optimizer (you can only play maps with up to ~25k variables anyway) and includes initial values like string paths (which it can obv compress worse).
 
Level 5
Joined
Jan 23, 2014
Messages
152
@WaterKnight: That solves my problem. I thought that variables would be about 30-80kb each hahaha. I really appreciate the effort. and wow! that's a lot of variables
 
Status
Not open for further replies.
Top