- Joined
- Sep 6, 2013
- Messages
- 6,742
About
gg= generated global
Here's a related tutorial explaining what a gg is: [Mini-Tutorial] Generated Globals
A gg is a global variable that is automatically created for prelaced objects that are used in triggers. Like preplaced units, doodads, cams, items, sounds, triggers, or regions.
In this thread I explain a short theory I have about when gg's are created, how they are kept in map, and when they are removed again.
The war3map.j file is created each time we save/built a map, so then is decided if to create or to remove gg's.
Shortly in before, I explain what is meant with "creating" or "removing" a gg variable for a map.
The gg variables are part of the globals block in the war3map.j file. So when we're speaking of "removing" a gg, it actually means Editor does simply not put it into the .j file, but it's not really removed from there. And "creating" does mean the gg var will be added to the .j file.
.wtg = GUI triggers
.wct = Custom Script / JASS triggers
.j = jass ( automatically generated output code, based on GUI triggers + JASS triggers)
When is a gg created?
When a GUI trigger references a preplaced object, this information is stord in the GUI .wtg file.
From here on, the gg will be created in the .j file. The gg can be used in JASS triggers, too.
But if you try directly to use a gg in JASS, without having a reference in .wtg / GUI file, it will throw a syntax error, saying this gg doesn't exist, as no gg is created on built.
When is a gg removed?
When you have a GUI trigger with a reference on a placed unit, let's say "gg_unit_Hpal_0001", and you remove the GUI trigger, it does following:
Conclusion
So the design is not very good:
Situation:
On a side note, HiveWE does automatically create gg vars in the globals block, if required. A reference by JASS alone is enough, there's no reference in .wtg file needed.
gg= generated global
Here's a related tutorial explaining what a gg is: [Mini-Tutorial] Generated Globals
A gg is a global variable that is automatically created for prelaced objects that are used in triggers. Like preplaced units, doodads, cams, items, sounds, triggers, or regions.
In this thread I explain a short theory I have about when gg's are created, how they are kept in map, and when they are removed again.
The war3map.j file is created each time we save/built a map, so then is decided if to create or to remove gg's.
Shortly in before, I explain what is meant with "creating" or "removing" a gg variable for a map.
The gg variables are part of the globals block in the war3map.j file. So when we're speaking of "removing" a gg, it actually means Editor does simply not put it into the .j file, but it's not really removed from there. And "creating" does mean the gg var will be added to the .j file.
.wtg = GUI triggers
.wct = Custom Script / JASS triggers
.j = jass ( automatically generated output code, based on GUI triggers + JASS triggers)
When is a gg created?
When a GUI trigger references a preplaced object, this information is stord in the GUI .wtg file.
From here on, the gg will be created in the .j file. The gg can be used in JASS triggers, too.
But if you try directly to use a gg in JASS, without having a reference in .wtg / GUI file, it will throw a syntax error, saying this gg doesn't exist, as no gg is created on built.
When is a gg removed?
When you have a GUI trigger with a reference on a placed unit, let's say "gg_unit_Hpal_0001", and you remove the GUI trigger, it does following:
- Check if "gg_unit_Hpal_0001" is still referenced from anywhere else in the .wtg / GUI file
- Check if "gg_unit_Hpal_0001" is still referenced from anywhere else in the .wct / JASS file
- If it's not used anwehre else, the gg will not be created on map build.
- If it's still referenced from somewhere, it will keep this gg reference in the .wtg file. Even it's referenced only from .wct / JASS!
Conclusion
So the design is not very good:
- A reference in the .wtg / GUI trigger is required to create a gg.
- Once having a reference in .wtg / GUI file, a reference from .wct / JASS code is enough, for keeping this reference in the .wtg, even when the GUI trigger is removed.
- Referencing a gg alone from .wct / JASS code is not enogh, to create a gg.
Situation:
- Human Paladin 0001 exists on map ( would be "gg_unit_Hpal_0001" as a gg).
- There's no .wtg / GUI reference, so no gg will be created.
- Referencing gg_unit_Hpal_0001 directly from JASS alone will of course throw a syntax error, as explained before.
- Also, even writing a JASS comment like "// gg_unit_Hpal_0001" will lead to a syntax error!!!
The editor does not evaluate the trigger comment correctly, and thinks I'm trying to reference a gg that doesn't exist. Based on this assumption editor tries to use gg_unit_Hpal_0001 from then on in the .j file. Specifically, when preplaced units are created. But as no gg is created due to having no reference from .wtg / GUI, it will throw a syntax error.
So the error does not occur at the "//gg_unit_Hpal_0001" part, because this is valid JASS comment, but it occurs in the code where the unit is created, that gg_unit_Hpal_0001 is used:
set gg_unit_Hpal_0001 = CreateUnit( ... )
... instead of the normal way, if there's no gg used:
set u = CreateUnit( ... ) // "u" is just a local variable
On a side note, HiveWE does automatically create gg vars in the globals block, if required. A reference by JASS alone is enough, there's no reference in .wtg file needed.
Last edited: