Pertex wrote:Hmmm, double seems to be buggy. Alex added some functions for 5.3 , but there seems to be some basic problems
<game name="test">
<start type="script">
msg(game.var)
</start>
<var type="double">1.2</var>
</game>
returns 12 instead of 1.2 so you can't work with stringfunctions.
It looks like in 5.3 this returns 1.2 correctly.
As for original poster. I think something like the following will work. Not sure it is elegant but it should work. Have your original function call a new function which:
- converts your double to a string
- split the string using '.'
- select the first item in the split (essentially your integer)
- converts integer string to Integer
Example:
<function name="conv" type="int">
x = 1.1
conv_to_int (x)
</function>
<function name="conv_to_int" parameters = "value" >
split_value_list = NewStringList ()
string_value = ToString (value)
split_value_list = split(string_value,".")
string_integer = ListItem (split_value_list,0)
result = ToInt (string_integer)
msg(result)
</function>