Don't you just hate doubles? Those pesky little variable types keep crashing your game in any place you need Integers. "If only there was a way to turn a double into an integer!" - a stereotypical woman in a commercial. Well now you can with Entropic Enterprises' new DOUBLE-TO-INTEGER Function 2000(Trademark Pending):
1) Create a "double_to_integer" function that will return an "Integer", and have "double" as one of the parameters.
2) Then insert this code into the function:
strdouble = ToString(double)
split_double = Split(strdouble,".")
strinteger = ListItem(split_double,0)
integer = ToInt(strinteger)
return (integer)
3) To use this function, simply do this:
// a pesky double variable
dbltest = 2.17
// this will turn dbltest into an integer
inttest = double_to_integer(dbltest)
//
msg("Double Value: " + dbltest)
msg("Integer Value: " + inttest)
Okay, so it just takes the numbers in front of the decimal place and returns it as a number, but I found it to be extremely useful.