• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

Question about this code.

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
//-- Sorry if this is the wrong forum for this. If wrong area where should I post jass issues?

--[[ The tutorial I was reading didn't make much sense, what does the gg_trg_TRIGGERNAMEHERE
What does the 'gg_trg' mean/stand for? --]]

//----------------------------------------------------------------------------------------------------

function test takes nothing returns nothing
local string a="This is a message"
call DisplayTextToForce( GetPlayersAll(), a )
endfunction


function InitTrig_Gold takes nothing returns nothing
set gg_trg_Gold = CreateTrigger()
call TriggerAddAction (gg_trg_Gold, function test)


endfunction
 
Level 10
Joined
Sep 16, 2016
Messages
269
Like Dr.Good said, you see them when converting GUI triggers into JASS. Usually I'd do it like:
JASS:
function test takes nothing returns boolean
    call BJDebugMsg( "This is test")
    return false
endfunction

function InitTrig_Trig1 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddCondition( t, Condition( function test) )
    set t = null
endfunction
 
Level 12
Joined
Dec 2, 2016
Messages
733
Also is there a way to not have it so when you press the undo key it not reset the trigger you're working on?

Or is there some sort of other jass editor I should use, and also get the colored syntax?
Thanks.
 
Level 8
Joined
Jan 28, 2016
Messages
486
"you see them when converting GUI triggers into JASS"

Wouldn't you also see them writing the code out manually instead of converting the trigger to jass?

When you create a trigger, the editor generates a global variable for it. These variables can be seen when you use the Trigger type actions [Eg: Turn of (this trigger), etc.] and are denoted with the gg_trg prefix. Even if it's empty, it still sets the variable when the game starts. Other objects can also have generated globals, such as regions or units that are placed in the game and have their own prefixes. Check the spoilers below. Otherwise you would be writing directly into the MPQ, where you would code triggers from scratch; there's nothing to generate the base trigger function.

  • Test
    • Events
    • Conditions
    • Actions
JASS:
function Trig_Test_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )
endfunction

JASS:
//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************

globals
    // User-defined
    hashtable               udg_Hash                   = null
    location                udg_Location               = null
    unit                    udg_Caster                 = null
    unit                    udg_Target                 = null
    group                   udg_TempGroup              = null
    integer                 udg_TempInteger            = 0
    real                    udg_TempReal               = 0
    timer                   udg_Clock                  = null

    // Generated
    rect                    gg_rct_Storage             = null
    trigger                 gg_trg_Map_Init            = null
    trigger                 gg_trg_Setup_Players       = null
    trigger                 gg_trg_Movespeed           = null
    unit                    gg_unit_ntav_0005          = null
    unit                    gg_unit_hwtw_0026          = null
endglobals



Also is there a way to not have it so when you press the undo key it not reset the trigger you're working on?

Or is there some sort of other jass editor I should use, and also get the colored syntax?
Thanks.

Not that I know of. It's usually a nightmare when coding with the vanilla Editor but you can convert a trigger in custom script to see Jass functions, copy what you need and then undo to return it to its GUI state. You can download JassCraft which is a stand-alone text editor specifically for Jass or the latest JNGP which also allows you code in vJass, among other things.
 
Last edited:
Level 43
Joined
Feb 27, 2007
Messages
5,422
Wouldn't you also see them writing the code out manually instead of converting the trigger to jass?
I think the confusion (not clarified by the above post) is that gg_trg_ is an arbitrary prefix for the variable. In JASS a variable can be named anything that doesn't start with a number, but all the Trigger Editor generated triggers have a standardized prefix for them. Good code ensures that your variable names don't collide with those in other bits of the code.
 
Level 12
Joined
May 22, 2015
Messages
1,051
I think the confusion (not clarified by the above post) is that gg_trg_ is an arbitrary prefix for the variable. In JASS a variable can be named anything that doesn't start with a number, but all the Trigger Editor generated triggers have a standardized prefix for them. Good code ensures that your variable names don't collide with those in other bits of the code.
This.

You will also see that your own variables in the variable editor are like this:
JASS:
udg_myVariableName

It stands for "user defined global". I think the "gg_trg_" part is "game global" and "trigger" so you know it's a variable defined by the game and that it's a trigger (also no naming collisions as mentioned by Pyrogasm). You can only work with global variables without using JASS, and it hides the funky names of the globals for you.

You will notice the "gg_" prefix on stuff like units already on the map (if you do "specific unit event", for example), and regions (they also have a secondary prefix like "trg" but I don't remember them exactly).
 
Level 8
Joined
Jan 28, 2016
Messages
486
You will notice the "gg_" prefix on stuff like units already on the map (if you do "specific unit event", for example), and regions (they also have a secondary prefix like "trg" but I don't remember them exactly).

It's gg_unit and gg_rct for units and regions respectively.

I think the confusion (not clarified by the above post) is that gg_trg_ is an arbitrary prefix for the variable. In JASS a variable can be named anything that doesn't start with a number, but all the Trigger Editor generated triggers have a standardized prefix for them. Good code ensures that your variable names don't collide with those in other bits of the code.

That's what I was meant to say. :p

Edit: I can't give you rep... :(
 
Status
Not open for further replies.
Top