Game Development Community

What is '-->', some new way of accessing instead of '->'???

by John Carroll · in Torque Game Engine Advanced · 02/09/2009 (2:47 pm) · 16 replies

I've noticed in some of the scripts (particularly the edit scripts) references to things have what appears to be a new operator (to me any way)'-->'. What does this mean, and how is it different than '->'?

on edit: ok, it appears that one of these means "the child named 'foo' (if foo is on the right), but what does the other one mean?

Examples:

if( !isObject( %this-->InspectorWindow ) )
{
// Load Creator/Inspector GUI
exec("~/missionEditor/gui/guiWorldEditorMissionInspector.ed.gui");
if( isObject( %guiContent ) )
%this.add( %guiContent->InspectorWindow );
}

and

if( !isObject( %this-->TerrainPainter ) )
{
// Load Terrain Painter GUI
exec("~/missionEditor/gui/guiTerrainPainterContainer.ed.gui");
if( isObject( %guiContent ) )
%this.add( %guiContent->TerrainPainter );
}

--John

About the author

Working on using Torque as an Image Generator for Tactical Simulations under laser and live fire conditions, for Law Enforcement/Military applications.


#1
02/09/2009 (6:14 pm)
They both appear to mean "Resolve the child using the internalName". I stepped through the code, using both -> and --> and in each case they resolved everything the same way, to their Object ID.
An interesting thing - If a child was not found, the result evaluated to "0", instead of "", like an unknown field would.
#2
02/10/2009 (11:07 am)
Yup, that's the conclusion we came to, but interesting that this is documented nowhere that I can find. I'd really like to hear from GG and what there take is on it...
#3
02/10/2009 (1:35 pm)
Im suscribing to this thread, maybe some caritative soul will answer oficially on the matter?
#4
02/10/2009 (1:53 pm)
Hmm, interesting...

New and undocumented things like this arouse my curiosity -- makes me wonder what else is hidden away and/or overlooked.
#5
02/10/2009 (1:57 pm)
Wow. That is interesting. I'll see if I can get an answer from a developer about this.
#6
02/10/2009 (2:19 pm)
Yup, my curiosity is also aroused by this, even though we think we understand the reason for at least one of these constructs...
#7
02/10/2009 (3:43 pm)
Ok. Just had a fun conversation about this with Matt Fairfax, Matt Langley, and Steven Garcia.

--> is used when trying to access a child control by it's internal name, as you suspected.


%this-->InspectorWindow

%this is the parent, InspectorWindow is the child control's internal name. So figuring out what it does, was easy. You guys already got this.

The fun part was figuring out why. Steven told me that he uses it a lot when modifying the GUIs that make up our editors. One thing we discovered is that you can have multiple child controls with different parents, and but share the same internal name. If you have multiple GUIs with the same control name, something is going to be overwritten.

Matt Langley found this comment in a TGB's source:

ConsoleMethod( SimSet, findObjectByInternalName, S32, 3, 4, "(string name, [bool searchChildren]) Returns the object with given internal namen"
"@param name The internal name of the object you wish to findn"
"@param searchChildren Set this true if you wish to search all children as well.n"
"@return Returns the ID of the object.")

Update: This is not specific to GUI controls. This is actually a SimSet feature.
#8
02/10/2009 (5:17 pm)
Thanks Michael!
#9
02/11/2009 (2:26 am)
I've used these operators alot... i think they came from TGB or Constructor.

Its just syntactic sugar for findObjectByInternalName()...

MySimSet->SomeInternalName is the same as MySimSet.findObjectByInternalName( "SomeInternalName", false ).

MySimSet-->SomeInternalName is the same as MySimSet.findObjectByInternalName( "SomeInternalName", true ).

Using this techinque with internal names is preferable to spamming the global TorqueScript object namespace with all sorts of GUI objects. Instead you only give names to top level GUI elements and use -> or --> to grab children on demand.
#10
02/11/2009 (11:40 am)
Awesome, I've got it now, thanks!!! (Will this be documented somewhere???)
#11
02/11/2009 (11:57 am)
It's definitely going in the Script Reference for Torque 3D. When I cycle back to the other engines I'll find a place for it there too.
#12
02/11/2009 (3:37 pm)
Bring on the sugar!! Any other similar goodies in the cookie jar?
#13
02/11/2009 (7:43 pm)
Very cool. Could someone familiar with this blog it? I tried sharing this post in IRC but not everyone could view it. We're in TGEA-private right now..
#14
02/11/2009 (8:01 pm)
@Steven - You can take my post and make a plan out of it... verbatim if you like.... but it would be cool if you gave some real examples with it.

Hey if its good i'm sure Michael will use some or all of it in the docs!
#15
02/11/2009 (11:03 pm)
@Tom - Good lord, you can call me Mich. We've met in person for crying out loud.

He has a point, though. Yes I will be documenting this. In fact, this reminds me go to through all of Orion's posts too. There are lots of cool TorqueScript syntax features re-discovered in the past year or so that need to be documented.

-> and --> are going in.
#16
02/11/2009 (11:05 pm)
Btw, let's decide this now. I encourage the OP (John) to blog about this. It's a nifty find. If he doesn't want to, then go ahead Steven. It is blog worthy.