Game Development Community

#define ConsoleFunction

by Adam Baratz · in Torque Game Engine · 11/06/2001 (6:17 pm) · 3 replies

I think I have a pretty good idea how this thing works. You feed it some basic info and it does a little setup for the scripting function. So with the NextToken function you'd get this out of the define:

static const char * cNextToken(SimObject *, S32, const char ** argv);
	static ConsoleConstructor gNextTokenobj(NULL,NextToken,cNextToken,"nextToken(str,token,delim)",4,4);
	static const char * cNextToken(SimObject *, S32 argc, const char **argv)

First line is the constructor for the function and the last is the top of the function itself. Two questions: what is the ConsoleConstructor thingy, and why does the function need a SimObject* passed to it (SimObjects seem like they're a building block object for more specific game objects, what else do they do?)?

#1
11/08/2001 (1:19 pm)
Anyone know about ConsoleConstructors?
#2
11/08/2001 (1:49 pm)
I don't have the code in front of me, but here goes:

The consoleconstructor is just a trick to get the function "registered" with the console system. Otherwise, the system wouldn't know which function to call when you call nextToken (or whatever)

As for the SimObject, in the case of nextToken, it is not used (and I think if you debugged the function, it would be NULL), but for other functions it is used. See tcpObject for a good example. It lets you create actual classes in script and have instance specific member variables for each instance.

The best way to figure this sort of thing out is using the debugger. Throw a breakpoint into the cNextToken function and check things out for yourself...

Josh
#3
05/05/2002 (9:44 am)
acctully their is a whole section for this on the online doc's ( and doxydoc's you can make yourself ) .. i'm a bit confused about it right now as i'm trying to access a class i'm making in the code with this function ... cant tell if i'm just missing somthing ( my C++ is not at the expert level ) or if their is somthing inportant being left out in the docs.