Page 1 of 1

removing numbers after decimal.

Posted: Sat Mar 24, 2012 6:15 am
by botje
my maxhp function returns 6666.0000

i just need the 6666, how do you remove that in lua?

thanx in advance ^.^

botje

Re: removing numbers after decimal.

Posted: Sat Mar 24, 2012 10:07 pm
by MiesterMan
I know how to do that in C++ for outputting to a printf, not sure if it works the same with lua.

http://www.lua.org/manual/5.1/

If it is the same than you put a .0 after it like:

Code: Select all

printf("You have %.0f hp.\n",hpFloat);

Re: removing numbers after decimal.

Posted: Sun Mar 25, 2012 9:33 am
by botje
awww... didnt work :(

Re: removing numbers after decimal.

Posted: Mon Mar 26, 2012 1:32 pm
by Administrator
Try this:

Code: Select all

printf("%d\n", someNumber);
%d will give you a whole number. %f will give you floating-point integers.

Re: removing numbers after decimal.

Posted: Tue Mar 27, 2012 5:02 pm
by botje
thanx admin, that worked great ^^