Game Development Community

ConsoleStaticMethod Question

by William Todd Scott · in Torque Game Engine Advanced · 12/02/2006 (4:31 pm) · 7 replies

Hi,

I am trying to call the getServerConnection function from script. It is defined in C++ as a ConsoleStaticMethod.

When I use this in script:

GameConnection::getServerConnection()

I get the error "wrong number of arguments.

When I use this in script:

getServerConnection()

I get the error that the function does not exist.


Can someone let me know the correct syntax for calling a ConsoleStaticMethod function from script? I looked through the engine and I see a couple of ConsoleStaticMethod functions defined, but no examples of them being called from script.

Thanks
Todd

#1
12/02/2006 (4:46 pm)
GameConnection::getServerConnection();

This works correctly in TGE, but I don't have a compiled version of TSE. It's either busted in TSE or maybe you made a typo?
#2
12/02/2006 (5:02 pm)
Hey Tony,

Thanks for responding.

I kept fumbling around with different options and I got the call to work with the following:

GameConnection::getServerConnection(GameConnection);

Which seems a bit wierd to me. I don't see any difference in the definition of getServerConnection() in TSE vs TGE. (I am comparing it to TGE v1.4).

I'll double check to make sure it wasn't a silly typo on my part.

Thanks for the response!
Todd
#3
12/02/2006 (5:12 pm)
The only thing I can think of is

ConsoleStaticMethod(GameConnection, getServerConnection, S32, 1, 2, "() Get the server connection if any.")

Might need to change to
ConsoleStaticMethod(GameConnection, getServerConnection, S32, 1, 1, "() Get the server connection if any.")

or
ConsoleStaticMethod(GameConnection, getServerConnection, S32, 2, 2, "() Get the server connection if any.")

I'm not sure if it the argument count is like a regular method or not.
#4
12/03/2006 (8:41 am)
Hi Tony,

I was thinking the same thing, but you mentioned that it is working in TGE....

It is actually defined as:

ConsoleStaticMethod(GameConnection, getServerConnection, S32, 2, 2, "() Get the server connection if any.")

and I am pretty confident that it should be:

ConsoleStaticMethod(GameConnection, getServerConnection, S32, 1, 1, "() Get the server connection if any.")

Todd
#5
12/03/2006 (9:01 am)
One last thing on this...

I don't have TGE 1.5.

If it is not defined as:

ConsoleStaticMethod(GameConnection, getServerConnection, S32, 2, 2, "() Get the server connection if any.")

in TGE 1.5, then it was fixed there and just needs to be fixed in TSE.

Todd
#6
12/03/2006 (3:54 pm)
Yeh, 1,1 looks right, since the function uses no variables
#7
12/04/2006 (7:37 am)
It's 1,2 in TGE 1.5 but you're correct in that it should be 1,1. Maybe someone should post this in a bug report.