Blockland Forums > Modification Help
round to nearest integer?
(1/2) > >>
Jorgur:
round to nearest integer?
Nexus:
mFloor()

it will always round down
Jorgur:
And mCeil will always round up. However, I need the nearest integer.
Nexus:
function mRound(%x)
{
   if(mFloor(%x) > (%x - 0.5))
      return mFloor(%x);
   else if(mCeil(%x) <= (%x - 0.5))
      return mCeil(%x);
   else
      return false;
}

I dunno, be creative.
Jorgur:
I figured it out:

         if(%hp - mFloor(%hp) < 0.5) %client.RPData.value["hp"] = mFloor(%hp);
         else %client.RPData.value["hp"] = mCeil(%hp);

But too bad Blockland doesn't have a function for it. :\
Navigation
Message Index
Next page

Go to full version