Introduction: Generated Globals
are globals that are generated variables for a certain handle. A handle
is any variable other than a string, boolean, code, integer, or real. If you open the common.j, the index of Warcraft natives (either extract it from the MPQ or get some JASS program such as JASSCraft that includes it), you will notice all the variables listed will extend handle, or extend a different variable which extends a handle. The five variables I mentioned, though, aren't handles because they don't extend handle, and they can't be directly created.
So, it generates a global for any variable type other than strings, boolean, code, integers, and reals. Purpose of this Tutorial:
Though generated globals are only used in certain functions, they are still important and it is good to know a bit about them. So after you read this tutorial, you shouldn't just go and generate globals because:
1 - In GUI, you can't even create or access generated globals unless you are using them for a particular function.
2 - In JASS, you have trusty NewGen globals. What are Generated Globals? Generated globals
are globals that WE creates for certain handles in your map. Take this for instance:
Trigger: Test 2065015788
- Unit - Footman 0001 <gen> is attacked
In this simple trigger, you have one <gen>. This actually means that it is a generated global. <gen> = Gen
As you can see, Footman 0001 is the generated global. Obviously, this is a preplaced unit on your map which the WE calls "Footman 0001".
If you convert this trigger to JASS by going to Edit | Convert to Custom Text
, it will be something like this in the initialization function (Init_Trig_Trigger):
// #### symbolizes the rawcode of the unit, or in this case, footman 0001
This is probably really confusing for you, so let me break it down.
- call = Tells that it is about to "call" or start a function
- TriggerRegisterUnitEvent = This is the function to be called. It registers a unit event.
- gg_trg_Trigger = This is a generated global for the current trigger you are in.
- gg_unit_####_0001 = This is the generated global for the unit that is being attacked, in this case, footman_001.
- EVENT_UNIT_ATTACKED = This is the type of event for the trigger.
In this, you'll notice two
generated globals. Yes, the current trigger is actually a generated global as well. So, every trigger is a generated global.
Generated globals, in JASS, always follow this standard:
- gg_TYPE_NAME gg = G
Type of variable to be generatedNAME =
This is the name of the variable, but in some cases for widgets (units, destructables, and items) it is the rawcode then the number of it on the map.
When you use a generated global, it must always have the prefix gg_TYPE
plus the name. This is similar to globals which require "udg_
" as a prefix.
Now that you basically understand the rules and what generated globals are, you can know walk out there with a clear knowledge of it. Summary:
Generated globals, to sum it all up, are just initiated handles in your map that are generated in WE to represent a certain handle such as a trigger or a widget. In fact, most of the times, generated globals are only used for triggers, widgets, regions, and cameras because others aren't visible in your map.
Now that you know this information, you can now know what those confusing <gens> mean.