• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Get your art tools and paintbrushes ready and enter Hive's 34th Texturing Contest: Void! Click here to enter!

[Lua] gg_ Variables created from pre-placed units etc. - Naming Logic

Level 4
Joined
Jul 27, 2015
Messages
35
Hi folks,

I feel like I'm going in circles and I'm trying to get to the bottom of this. So any pre-placed unit, region, destructable etc. gets assigned to a gg_something variable when the map is created, right - this also is true for a LUA map as far as I understand.

This variable name can be used to refer to specific, pre-placed objects in your script. In my example, the gate blocking the entrance to an area. I want to open it with this line of script

Code:
        ModifyGateBJ(bj_GATEOPERATION_OPEN, gg_dest_DTg7_0001)

I've derived this name by converting a JASS trigger to custom script, though I am scripting in LUA to be clear. See attached image of the object placed in editor, to sense check I got the name right!

Anyway, this script is simply not working - my debugger is telling me I'm trying to refer to a nil global, which suggests to me I have the variable name wrong!

So my questions are as follows:

1. Have I used the correct global variable name in this instance?
2. Is there a way to view in the editor what global variable name will be allocated to a given object?
3. Has someone (i couldn't find it) compiled the logic for the naming of these variables somewhere?
Bonus. Is this the wrong approach? Could I be generating these gates at runtime? If so, how would I best determine the coordinates to use... experiment and hard code them?

Many thanks for your attention. I'm quite frustrated and feeling stuck. :goblin_cry:
 

Attachments

  • DTg7 (Iron Gate).png
    DTg7 (Iron Gate).png
    1.7 KB · Views: 2
  • IronGate0001.png
    IronGate0001.png
    13.1 KB · Views: 2
Level 25
Joined
Feb 27, 2019
Messages
846
1.
The name is correct but the variable doesnt exist. It must be referenced in GUI to be assigned a variable. Its probably the case that destructibles are not assigned variables if theyre not going to be used and this is how they determined if it was going to be used or not.

2.
Theres gg (generated global?) and dest (destructible). The other two are object id and index which is basically a number that increases for each destructible placed. In your image the index is 0001 which iirc means its the second destructible placed on the map or the destructible with index 0001 was removed and when this destructible was created it was the first available index. In your image, the skin displays an object id, generally the skin is the same as the object id unless it was manually changed.

Bonus.
I suggest you try something yourself. Place a few destructibles on the map and reference one of them with a GUI action. Export map script. Using the info in 2, ctrl + f for the variable within the map script to see what happens. You could mimic how the map script creates and assigns the variable.
 
Level 4
Joined
Jul 27, 2015
Messages
35
Hi Duckfarter,

1.
The name is correct but the variable doesnt exist. It must be referenced in GUI to be assigned a variable. Its probably the case that destructibles are not assigned variables if theyre not going to be used and this is how they determined if it was going to be used or not.
You've saved me the initial frustration! Though I didn't want GUI triggers, I have created one with an action that refers to the destructable and that has indeed caused a global var for it to be created in the correct format. Means I'm not stuck here which is a nice start.

2.
Theres gg (generated global?) and dest (destructible). The other two are object id and index which is basically a number that increases for each destructible placed. In your image the index is 0001 which iirc means its the second destructible placed on the map or the destructible with index 0001 was removed and when this destructible was created it was the first available index. In your image, the skin displays an object id, generally the skin is the same as the object id unless it was manually changed.
Okay it works how I expected then, I really was just caught by the game not creating a var for each destructable... probably sensible in the long run??

Bonus.
I suggest you try something yourself. Place a few destructibles on the map and reference one of them with a GUI action. Export map script. Using the info in 2, ctrl + f for the variable within the map script to see what happens. You could mimic how the map script creates and assigns the variable.
I'll give this a go, though really the point of using the global vars was for easier arrangement / management of the various objects in the dungeon -during development- which means I preferably don't want to be hard coding this stuff I think, at least until I'm set on a final layout.

Appreciate the swift response, you've saved me a headache :grin:
 
Top