Game Development Community

Accessing object "names

by Anthony Ayers · in Torque X 2D · 05/08/2008 (6:15 pm) · 5 replies

I am familiar with how to look up an object with the "find object" method, but how can one actually return the objects name for reference. For example, i have two pc objects on screen with object names: "bill" and "Steve". When I click on bill, I want to do X and when I click on Steve I want to do Y. I would simply like to return the object name I associated with each object in torque x builder. Any help would be much appreciated!

#1
05/08/2008 (6:48 pm)
What are you asking for exactly? The obj.Name property has the object's name.
#2
05/09/2008 (12:27 pm)
Yes, thats what I'm after - however, whenever I access an object with a name I get "unknown" instead of the name given in TXB????

Even after creating a new t2dSceneObject and filling it using the FindObject method - passing in a specific objects name - I still get "Unknown"???
#3
05/11/2008 (5:04 pm)
Post the XML of the object in your .txscene file and then post the code you're trying to use to find the name of that object.
#4
05/12/2008 (5:35 pm)
Is it a template object? If so then the instance of your object will get an auto-generated name when you register it; only the template will have the name defined in the XML.

I believe you can set the name before you register it with the Torque object database, then that instance will have the given name.
#5
05/13/2008 (9:37 am)
Ok. So I guess I was a bit confused as to why TXB would have a place for the object name, but the object wouldn't refernece that name in run-time. THx, Russell for the answer I was looking for. Since the objects are templates, they don't reference the name given in TXB! So, if I just manually name the templates in code before registering them, I can access their object names just fine. Thanks guys.