rounding numbers in script?
by Van der planken Roel · in Technical Issues · 09/19/2002 (2:48 pm) · 3 replies
how can I round a number so it there is no comma in it..
%obj.getDataBlock().maxDamage - %obj.getDamageLevel()
the result of this calculation can be somthing like 75.42 but I would like that it is rounde to 75
%obj.getDataBlock().maxDamage - %obj.getDamageLevel()
the result of this calculation can be somthing like 75.42 but I would like that it is rounde to 75
#3
You would then just use:
%val = mRound(74.52);
09/20/2002 (10:28 am)
Or for your more traditional rounding function, you can use the following:function mRound(%num)
{
if ((%num-mFloor(%num) >= 0.5)
{
%value = mCeil(%num);
}
else
{
%value = mFloor(%num);
}
return %value;
}You would then just use:
%val = mRound(74.52);
Torque Owner Mike Stoddart
Edit: Here's the document link:
www.garagegames.com/downloads/TGE_Console_Cmds.rtf