Warcraft III: MapsModelsSkinsIconsSpellsToolsTutorials
WC3 JASS: Code SnippetsJASS and vJASS Spells and SystemsJass Tutorials
Chat @Discord

Author Topic: [Mini-Tutorial] Generated Globals  (Read 221 times)

  • Rookie - level 1
  • *
  • Posts: 45
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
[Mini-Tutorial] Generated Globals
« on: November 20, 2010, 09:02:35 PM »
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 652459487
   
           
  • Trigger
  •     Events
  •         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  [Select]
  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
  3.  
  4. //blank line
  5.  
  6.  

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 = 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.
 
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.
« Last Edit: October 29, 2017, 06:18:37 PM by moyack »

 

[TUTORIAL] How to take a screenshot in Android devices

Started by moyackBoard Game Development

Replies: 2
Views: 8939
Last post October 19, 2013, 09:32:35 AM
by moyack
AI Editor, a graphical tutorial

Started by moyackBoard Tutorial Zone

Replies: 5
Views: 12663
Last post August 09, 2017, 07:57:39 AM
by moyack
Tutorial about jetscript??

Started by moyackBoard JetScript

Replies: 1
Views: 5164
Last post July 14, 2013, 03:47:07 PM
by Sourc[e]x
Blizzard Modding Information Center Starcraft II Modding Information Center Wacraft III Modding Information Center WC3JASS.com - The JASS Vault Chronicles of Darkness - A Warcraft III mod Jetcraft - A Starcraft II mod Troll Smash - A Warcraft III Arena
  Mod DB - Change the Game Power of Corruption - A Warcraft III altered melee map Chaos Realm - The world of Game modders and wc3 addicts Follow us on Facebook!!