Game Development Community

What happens when a function doesn't exist in TorqueScript?

by Adam Johnston · in Torque Game Builder · 09/26/2005 (10:29 am) · 9 replies

I have seen the list of the TorqueScript functions and even
when there are a lot I was wondering What happens when
I need a function that isn't defined there?
For example: spline functions (just for example: Bezier curves)
(If they exist please think like they are not defined)
There is a way to add this functions to the core engine?
someone has done this?. I'm talking of creating my own TorqueScript
function: mBezier (...) in C++ and using after by my scripts.
Of course this could be recoded totally in script.
But I think this is slower (?). (maybe Bezier not, but I can think
in other functions)
I like to know if somebody has put time intensive
functions in C++ code before.

#1
09/26/2005 (10:41 am)
There's a resource for modifying the code like this:

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7736

Although, I would probably wait for the new version to come out because the fx extentions will change I believe...
#2
09/26/2005 (10:43 am)
@Steve: thank you!
#3
09/26/2005 (10:56 am)
Steve is right, the next version of T2D will include the extension changes... for example

fxStaticSprite2D will become t2dStaticSprite

it really won't be a hard thing to prepare/modify for though :)
#4
10/18/2005 (2:36 pm)
I was playing adding a test function "Double" and it was simple:

I added this code to mConsoleFunctions.cc (line 136)

ConsoleFunction( mDoubleTest, F32, 2, 2, "(float th) Multiply by 2 th.")
{
   return((2 * dAtof(argv[1])));
}

recompiled and tested in the console, it worked.
I'm forgeting something??
#5
10/18/2005 (2:43 pm)
Looks good to me
#6
10/18/2005 (2:50 pm)
Looks real good for a ConsoleFunction!

Keep in mind that the ConsoleMethod is just slightly different, in that you need to include the ClassType as your first parameter, and keep in mind that 2 of the argv's are reserved for Torque use (argv[0] as is the case for ConsoleFunction, and argv[1] which is available for use as the first user parameter in ConsoleFunction, but not available for use in ConsoleMethod).

In other words, if this example happened to be a ConsoleMethod instead of a ConsoleFunction, you would be using argv[2] as your "arg" to multiply.
#7
10/18/2005 (3:39 pm)
Ah... thank you guys I'm relieved. :)

Every time I dive the source code I wonder
the amount of ingenuity and effort
put in this formidable program.

@Stephen: thank you for clarifying about the number of params.
#8
10/18/2005 (5:45 pm)
K, that's never happened before--someone mistaking my meager coding knowledge for Melv's :)

Thanks for the compliment, no matter how unintended it was!
#9
10/19/2005 (9:53 am)
Oh! sorry about the mistake @Stephen. I was in a hurry

as you said to me would be a honor too be mistaken by melv :)