Game Development Community

New engine functions not script-visible

by Steven Peterson · in Torque Game Engine · 10/15/2005 (1:33 pm) · 3 replies

I've been trying all day to access the individual x,y coords from getWindVelocity() in my scripts. Can't figure it out. So I added a new function in "Sky" right below getWindVelocity.

However when I call it in the scripts, same as I would call Sky.getWindVelocity() I get an error in the console. The new function as seen below is "getWindVelocityXY".

Any ideas where I've gone wrong or how I can access these individual values?
I'm going crazy banging my head against this one, when it should be trivial... :-(

Much Appreciation,
Raven


sky.h
------------
Point3F getWindVelocity();
void getWindVelocityXY(int &, int &);
------------


sky.cc
------------
Point3F Sky::getWindVelocity()
{
return(mWindVelocity);
}

void Sky::getWindVelocityXY(int &x, int &y)
{
x = mWindVelocity.x;
y = mWindVelocity.y;
}
-----------


script
-----------
Sky.getWindVelocityXY(%windX, %windY);
-----------


console
----------
zelda/server/scripts/weather.cs (281): Unknown command getWindVelocityXY.
Object Sky(1480) Sky -> SceneObject -> NetObject -> SimObject
----------

#1
10/15/2005 (1:47 pm)
Have you tried to use getWord() on what getWindVelocity returns?
Also, when you create a function you want available in script, you will have to expose it as a console method.
Note how this is done for getWindVelocity() in sky.cc:

ConsoleMethod( Sky, getWindVelocity, const char *, 2, 2, "()")
{
   char * retBuf = Con::getReturnBuffer(128);

   Point3F vel = object->getWindVelocity();
   dSprintf(retBuf, 128, "%f %f %f", vel.x, vel.y, vel.z);
   return(retBuf);
}

Search for resources on console methods if you're not up on them.

--
Hans
#2
10/15/2005 (2:51 pm)
Thanks Hans - this'll be a big help!

I was looking around for somthing like getWord() but never found it. Didn't know what it was called...

I skimmed alot of the script docs, but must have missed the section on console methods. This would appear to answer both my questions then! :-)

Thanks!
Raven
#3
10/15/2005 (5:07 pm)
There is a whole chapter on it.