• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Constant globals - when to use them

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

I was just curious how VJASS handles all the constant globals that are declared.

For example, suppose I have three constant global integers, with different names, but the same value. Does VJASS just collapse them all to a single constant global variable?

I've been using constant integers for all my important indices or values, and a lot of these tend to be 0 or 1, e.g. "QUIT_BTTN" is equal to 0, as it denotes which button in a dialog is the exit button.

What about constant strings? For example, I might use constant strings in a dialog system, since it makes it easy to modify how the speech looks (I just modify the strings in the globals section, rather than search through the actual script and change the DisplayText calls).
 
Hi,

I was just curious how VJASS handles all the constant globals that are declared.

For example, suppose I have three constant global integers, with different names, but the same value. Does VJASS just collapse them all to a single constant global variable?

No i don't believe it does.

I've been using constant integers for all my important indices or values, and a lot of these tend to be 0 or 1, e.g. "QUIT_BTTN" is equal to 0, as it denotes which button in a dialog is the exit button.

What about constant strings? For example, I might use constant strings in a dialog system, since it makes it easy to modify how the speech looks (I just modify the strings in the globals section, rather than search through the actual script and change the DisplayText calls).

Each variable increases map size. But when doing this it is easier as it is easier to edit the variables and easier to read the script.
It takes a ton of variables to actually matter though.
I think each variable is about 4bytes but i may be wrong. There are a lot of discussions on variables and how much space they take up.
I wouldn't worry about having a lot of variables in your map.

Vexs map optimizer might reduce the variables but i have never used it or looked into it for reducing variables.
 
Status
Not open for further replies.
Top