Game Development Community

'->' and '-->' operators in TorqueScript

by Jason Viterna · in Torque 3D Professional · 11/18/2009 (2:23 pm) · 5 replies

Could someone direct me to a good resource that explains what these (and other) operators do in TorqueScript? For some reason I've been having issues particularly with the '-->' operator in EditorGui::init in file EditorGui.ed.cs .

After I've executed this segment of code:

if( !isObject( %this-->ToolsPaletteWindow ) )
   {
      // Load Creator/Inspector GUI
      exec("~/worldEditor/gui/ToolsPaletteGroups/init.cs");
      exec("~/worldEditor/gui/ToolsPaletteWindow.ed.gui");
      
      if( isObject( EWToolsPaletteWindow ) )
      {
         %this.add( EWToolsPaletteWindow );
         EWToolsPaletteWindow.init();
         EWToolsPaletteWindow.setVisible( false );
      }
   }

isObject(%this-->ToolsPaletteWindow) still returns 0. I've changed this code to the code printed below (and changed all other relevant checks in other files) to fix the issue temporarily.

if( !isObject( %this.ToolsPaletteWindow ) )
   {
      // Load Creator/Inspector GUI
      exec("~/worldEditor/gui/ToolsPaletteGroups/init.cs");
      exec("~/worldEditor/gui/ToolsPaletteWindow.ed.gui");
      
      if( isObject( EWToolsPaletteWindow ) )
      {
         %this.add( EWToolsPaletteWindow );
         %this.ToolsPaletteWindow = EWToolsPaletteWindow;
         EWToolsPaletteWindow.init();
         EWToolsPaletteWindow.setVisible( false );
      }
   }

#1
11/18/2009 (3:16 pm)
Both "->" and "-->" do lookups through a parent object for its children's "internalName".

"->" is a single level lookup.
"-->" is a multi-level lookup.

No 2 objects can have the same names in T3D. Which is why the proper use of parent/child relationships through internal names can be really useful.
#2
11/19/2009 (5:31 am)
This is normally used only for the GUI portion of things.
#3
11/19/2009 (6:01 am)
My life changed when I found out about internalName and the -> and --> operators. Coding complex GUIs was such a chore before that, and involved same-name object hacks and whatnot. Dynamic GUIs (with replicated elements that are made of several sub-controls) are infinitely easier using this.
#4
11/19/2009 (2:44 pm)
Alright, that's good to know, however I'm still not sure what could be causing this bug. I'll look into it some more, but any insight into what could be breaking this is appreciated.
#5
11/19/2009 (4:51 pm)
Looking at it again... it does look like a bug. Try storing %this-->ToolsPaletteWindow in a local variable before using it and echo its value on the console to see what is being returned.