Warcraft 3 documentation
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

[Mini-Tutorial] Generated Globals No New Posts Jass Tutorials

Started by

0 Members and 1 Guest are viewing this topic.

[Mini-Tutorial] Generated Globals
on: November 20, 2010, 09:02:35 PM

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:
        Unit - Footman 0001 <gen> is attacked

In this simple trigger, you have one <gen>. This actually means that it is a generated global.
<gen> = Generated Globals
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):
Code: jass
  1.     call TriggerRegisterUnitEvent( gg_trg_Trigger,gg_unit_####_0001,EVENT_UNIT_ATTACKED)
  2. // #### symbolizes the rawcode of the unit, or in this case, footman 0001
  4. //blank line

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 = Generated Global
TYPE = Type of variable to be generated
NAME = 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.
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.
« Last Edit: October 29, 2017, 06:18:37 PM by moyack »


Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   Power of Corruption, an altered melee featuring Naga and Demon. Play it now!!!   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod   WormTastic Clan (wTc)   Warcraft RESOURCES Reforged: Modelos, mapas, proyectos y mas...