Converting Float to Int? [SOLVED]

SunYatSen

  • Posts: 59
Hello all!

I am trying to integrate a website's API into my game and am trying to put it a scoring system. I have a score attribute(that I made with code block), however, when I make a call to the API code, it (the API code) expects an integer value. Since Stencyl seems to automatically make number variables into floating point numbers, does anyone know how to convert that float to an int? I looked around and tried a few things, but couldn't get it working. I could also just create a new variable using code, but that too I am a little lost at. If anyone had any idea how to do any of these(changing types would be preferred!) I would really appreciate it! Thanks :D
Tried using:
int(x:Float):Int

that I found on http://api.haxe.org/Std.html#parseFloat  , but I'm pretty novice at coding so unsure what I keep getting errors when trying to launch game.

« Last Edit: April 23, 2015, 05:31:07 am by SunYatSen »


ETHproductions

  • *
  • Posts: 430
If you're using code, you usually need to use the full name of the function, which includes the name of the class it is found in. In this case, as the class name is Std, you should use Std.int(). If you're using blocks, try using the round block, as rob1221 suggested.
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

SunYatSen

  • Posts: 59
Cool it worked! Thanks guys, helpful as always! :D