Game Development Community

Object variables don't work in Gui Variables...

by Gina-Marie -Netjera- Hammer · in Torque Game Builder · 07/25/2006 (8:10 pm) · 0 replies

I recently learned to use the "Variable" field to specify which variable a gui text element is to track. All of my elements are GuiTextCtrl objects on a GuiControl using the GuiWindowProfile, as was suggested in the Gui Mini Tutorials on the TDN site.

I have a health variable attached to the player object in the editor: $PharaohPlayer.myHealth. I also have several other variables that are all globals. All variables are updated dynamically across several scripts, and I implemented them in the console before ever applying them to a gui, so I knew they all worked.

When I started applying them to the GuiTextCtrl objects, all variables of the format "$someVariable" worked fine. The Gui controls initialized to the values of the corresponding variables, and updated correctly. However, this variable $PharaohPlayer.myHealth, did not work in the variable field of the editor, or when entered in script as Variable = "$PharaohPlayer.myHealth";. Whenever I checked the variable value of $PharaohPlayer.myHealth, the variable would be updating, but when I watched the gui element in Torsion, the value was always "".

I finally set $PharaohPlayer.myHealth = $PharaohHealth in my player.cs, then I updated all the calls to use $PharaohHealth instead of the longer object variable. Finally, I changed the gui variable field to read: Variable = "$PharaohHealth"; and it worked.

Obviously, it doesn't like the "." nomenclature, and I seem to remember it has that problem when loading certain image files as well, so this must be part of that same bug.