why 25 * 1.3 gives 25 in construct?

0 favourites
  • 7 posts
From the Asset Store
25 high-quality robots. This asset is perfect for a side scrolling game, or even a turn based RPG type game.
  • doing this code

    where Stats.At(Hardness,1) equal to 1.3

    which is shown in the print console

    but the result as you can see is equal to 25 instead of 32.5 which is right value of 25 * 1.3

    is it bug or feature of construct?

  • It's not a bug, this is how strings are concatenated. Add round brackets:

    ... & "/" & (25*Stats.at(Hardness,1))

  • It's not a bug, this is how strings are concatenated. Add round brackets:

    ... & "/" & (25*Stats.at(Hardness,1))

    added, nothing changed

    also, we can't use int in this case, because 1.3 will be rounded to 1, is it always like this? I never had such a problems

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, I can use float() to convert this array value into a number, and the calculation becomes right

    but the strange thing, in another block Stats.at(Hardness,1) this value working as expected without float or anything

    as for me, it is not right when this basic things working different in the different places

  • Maybe the value is stored as string in the array? You can test this by printing Stats.AsJSON to console log. If the value is shown as "1.3", then it's a string.

  • Maybe the value is stored as string in the array? You can test this by printing Stats.AsJSON to console log. If the value is shown as "1.3", then it's a string.

    Yes, it is a string, but I'm wonder why I didn't experienced this situation before, in previous years

    Anyhow, I will always use float() now, to avoid this situations

  • To be clear the issue is from multiplying a number by text.

    Usually construct lets you know that it can’t do that when you write

    25*”1.3”

    So since the value is in an array it doesn’t know if it’s a number or text till runtime. And construct doesn’t really ever give runtime errors. So it just silently doesn’t do anything when trying to multiply a number by text.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)