How to convert float to int?

I’ve tried:

int(thefloat);
(int)(thefloat);
math.round(thefloat);

function floatToInt(thefloat){
local theInt = 1;
theInt = thefloat;
return theInt;
}

and anything else I could think of with no luck.

On a related note…is there any other Squirrel references or supplemental references that could be useful as I’m learning? The official reference manual seems to be lacking.

I think you want tointeger() as shown below.

Default delegates
Except null and userdata every squirrel object has a default delegate containing a set of functions to manipulate and retrieve information from the object itself.

Integer

tofloat()

convert the number to float and returns it

tostring()

converts the number to string and returns it

tointeger()

returns the value of the integer(dummy function)

tochar()

returns a string containing a single character rapresented by the integer.

weakref()

dummy function, returns the integer itself.

Float

tofloat()

returns the value of the float(dummy function)

tointeger()

converts the number to integer and returns it

tostring()

converts the number to string and returns it

tochar()

returns a string containing a single character rapresented by the integer part of the float.

weakref()

dummy function, returns the float itself.

http://squirrel-lang.org/doc/squirrel3.html#d0e457

Yep, that’s what I wanted. I’m just blind :slight_smile:

Thanks