Game Development Community

Returning F64 in consoleMethods

by Bruce Robertson · in Torque Developer Network · 05/29/2006 (12:16 pm) · 2 replies

I tried returning a F64 in a console method, but received some strange compiler errors (which disappered when I changed it to another data type, i.e F32 / bool etc.


My Method is (simplified version):

ConsoleMethod( AIAffectivePlayer, getRelationshipRating, F64, 2, 2, "()"
"Get Relationship Rating")
{
F64 tempRating;
...
...
...
return tempRating;

}

the errors are:
c:\torque\sdk\engine\game\aiaffectiveplayer.cpp(63) : error C2059: syntax error : ')'
c:\torque\sdk\engine\game\aiaffectiveplayer.cpp(63) : error C2065: 'conmethod_return_F64' : undeclared identifier
c:\torque\sdk\engine\game\aiaffectiveplayer.cpp(63) : error C2146: syntax error : missing ';' before identifier 'cAIAffectivePlayergetRelationshipRating'
c:\torque\sdk\engine\game\aiaffectiveplayer.cpp(63) : error C2664: 'ConsoleConstructor::ConsoleConstructor(const char *,const char *,StringCallback,const char *,S32,S32)' : cannot convert parameter 3 from 'F64 (__cdecl *)(SimObject *,S32,const char **)' to 'StringCallback'


Looking at these errors it seems as if returning this data type is not defined (second line), which would be quite strange.
I am using Torque 1.4 and Visual Studio Express 2005

#1
05/29/2006 (1:20 pm)
As far as I know, you can only return const char *, S32, F32, void, and bool. If you look in console/console.h, you might be able to add F64. If that doesn't work, you could build a string and have your ConsoleMethod return that instead.
#2
05/30/2006 (7:58 am)
Thanks William,
I had a look at the console files, and you're right about the registered return types. Returning a string would also be way to work around it.

I also tried adding F64 to the console file, but to no avail.
It's not a big deal, as I can use a float, but Im it could be something that someone could have a problem.