Converting integer to float

BlitzMax Forums/BlitzMax Programming/Converting integer to float

Takis76(Posted 2015) [#1]
Hello,

I have one question and I would like to tell me if is it possible.

In my game I have my hit points percentage bar for the player.
When the player will be hit by monster loses hit points.
The hit points of the player is a floating variable which divided my the max hit points to present the percentage of the remain hit points.

Then the player finds a healing potion.
When the player drinks the healing potion I generate random hit points for the player according to the hit dice (Dungeons and Dragons rule) for example one small healing potion generates 1d4 (Which means 1 dice 4 sides) hit points.

So I run the rand(1,4) function to generate those hit points but this rand generates integer so the floating variable of the hit points are is not able to be added in the integer variable.
So how is it possible to convert this integer to float?

Thank you :)


Brucey(Posted 2015) [#2]
You can add an int to a float without an problems.
SuperStrict

Framework brl.standardio
Import brl.random

Local f:Float = 10.5
Local i:Int = Rand(1, 4)

f :+ i

Print f



Takis76(Posted 2015) [#3]
Thank you , but it seems the float(rand(1,4)) is working too.
:)