Game Development Community

Getting DefineConsoleFunction to work

by Rex Hiebert · in Torque 3D Professional · 06/15/2011 (8:27 am) · 3 replies

I have a simple function that i am trying to expose to the console

DefineConsoleFunction(getStringMD5, const char *, (const char *stringVal),, "getStringMD5(string)")
{
//other code here
}

It compiles fine and doesn't give any warnings. But when i try to call it from script or on the command line I get "Unable to find function getStringMD5"

I even tried it as DefineEngineFunction. Not really sure what the differences are but neither work.

Any ideas?

#1
06/15/2011 (9:45 am)
Ok... maybe it wasn't linked properly. After moving and renaming the file I now get the following errors:

error C2059: syntax error : 'constant'
error C2065: 'argc' : undeclared identifier
error C2065: 'argv' : undeclared identifier

These are not items in the code. It seems as if the macro is not working properly on the DefineConsoleFunction.

Oh, and here are the includes:
#include "console/console.h"
#include "console/consoleInternal.h"
#include "core/strings/stringUnit.h"
#include "console/engineAPI.h"
#include "console/consoleTypes.h"

What am i missing?
#2
06/15/2011 (9:54 am)
Is that double comma just a typo in the post?

(const char *stringVal),,
#3
06/15/2011 (10:03 am)
Not a typo. Looking at the other DefineConsoleFunction calls in the code you can see that they have that as well. That is the spot for the default value but a value is not required.