Game Development Community

Converting GameBase to const char

by Hasitha · in Torque Game Engine · 03/11/2009 (3:46 pm) · 4 replies

I've been a scripter and an artist from the start, but I'm interested in attacking the code. I've written a ConsoleMethod and I want it to be able to return a const char that has been casted from a GameBase object.
How do I convert the GameBase into a const char?
How do I do this?

I'm really a Java programmer. Also, is there a clear cut API that lists all the functions and fields for all these classes (with explanations) that I can use?

Heh. I tried toString().toCharArray() and didn't seem to work :)

#1
03/11/2009 (4:39 pm)
Hasitha,
you have a GameBase or a pointer to a GameBase and want to cast it to a const char* ? that seems a little funky, sort of like casting a rectangle to a network connection or something: they're fundamentally different types of entities.

what information do you want the ConsoleMethod to return ?


#2
03/11/2009 (4:47 pm)
Well, basically I've got a camera object, and I want to return the player it's attached to. I didn't really find a function anywhere that does this in the code. Doesn't each GameBase object have an ID? Is it possible to obtain the ID?
#3
03/11/2009 (6:59 pm)
.getID() will return the id of the object. To get it as a string, I think there is a function along the lines of getStringID()? If not, you'll just have to convert that S32 from getID() to a char*. By the way, the ID's of objects are only used in script and for Sim::findObject calls, so you may want to make it more clear next time the value you want to return for the object.
#4
03/11/2009 (7:34 pm)
Hmmmm...is there any way for finding what a camera's player object is? I'm using the Advanced Camera, BTW. I noticed that in the resource, there was a getPlayerObject function defined in the header, but no function in the .cc, so I went ahead an wrote one that returns a GameBase, the player object. My main problem is that the camera is not following the player most of the time, and so I want to check what the camera is following at any given moment. I'm betting there is a nice, easy method for this all on the scripting side, but I'm just not seeing it.