Min/max
by James Sayer · in Torque Game Builder · 11/11/2005 (6:59 am) · 3 replies
Is there a min(x,y) function that returns the lowest number between x and y. Say, mMin()? And a max() function? I thought this would be available, but I can't find it. I would rather not do it in script.
About the author
#2
Oh well, you could add the following anywhere to provide them..
Hope this helps,
- Melv.
11/11/2005 (9:55 am)
You know, all this time I never noticed that there wasn't a min/max for the scripts!Oh well, you could add the following anywhere to provide them..
// Minimum of two values.
ConsoleFunction( mMin, F32, 3, 3, "(float a, float b) - Returns the minimum of two values.")
{
return getMin(dAtof(argv[1]), dAtof(argv[2]));
}
// Maximum of two values.
ConsoleFunction( mMax, F32, 3, 3, "(float a, float b) - Returns the maximum of two values.")
{
return getMax(dAtof(argv[1]), dAtof(argv[2]));
}Hope this helps,
- Melv.
#3
11/12/2005 (5:41 pm)
Thanks for that, Melv. This should be put into the TGE CVS head, shouldn't it? It's shameful to lose all these handy little additions in the forum abyss.
Torque Owner Jason McIntosh