Game Development Community

Getting pointers from id numbers

by University Of Texas 1 · in Torque Game Engine · 12/15/2003 (5:15 pm) · 1 replies

I've created some ConsoleMethod within the engine...

ConsoleMethod( ClassX, methodY, etc...) {
}


Within that console method, I need to convert an id number that's being passed from script into a pointer to the object that that id number references.

So, for instance, from script:

%player = new Player();
...
... //stuff here
...
%classXInstance.methodY(%player);


The id number of that %player argument is passed to methodY, but that needs to be converted to a real pointer to the object if I'm going to do anything useful with it.

Can anyone advise on the right way to go about this?

Thanks,
DMC Lab Guy

#1
12/15/2003 (5:45 pm)
Player *foo;

if(Sim::findObject(dAtoi(argv[2]), foo))
    object->doStuff(foo);
else
    Con::errorf("Could not find specified object.");