Construct 2 can't calculate?..

0 favourites
  • 12 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • I am sure it can, but here is my problem when I ask construct 2 to do this

    (36.00360037-36) I get this 0.003600370000000908

    But what I want is 0.00360037

    What am I doing wrong here?

    In case you wonder why I want that. It is a code who reads out every number to create a certain situation

    The amount of zeros in between are so that when it rounds it down/up I wont get a different number.

    But I tested this with simply and only asking C2 to do this (36.00360037-36) on a empty layout with no events.

  • There was a discussion here recently and the basic idea is that "on computers floating point numbers are never exact" - so you cannot be sure of the number of digits after the point.

    You can read about it here, for example: http://docs.oracle.com/cd/E19957-01/806 ... dberg.html

    If the number of digits is always the same you could do something like Result = left(str(36.00360037-36,NumberOfDigitsYouNeed)) else you could rethink the approach.

  • Somebody is perfectly right. C2 is fine works wonder for me

  • See "Expecting math calculations to be exact" in common mis-used events and gotchas.

  • OK i understand how it works. I'll try a different wat.

  • Maybe you can help me. What I want is certain id to be picked. I know how to do it, however the problem is that I need like 10 different Id or more to be picked. I would to give a code. for example 353627 and that Id 35 ,36 ,27 will be picked. They are all the same object. And I need the id to be different for each level. I can't do it manually since every level is the same layout and event sheet but different variables. That is been passed on the moment the player clicks level* .

    I tried so many things but I can't get it to work. Maybe you guys have an idea. I know it isn't easy(at least not for me). Thanks so far for the help.

  • This is what I did so far and it works almost perfect since I can only do it for a max amount of numbers. If I use more C2 can't handle the amount. So I would have to keep repeating this method. Maybe someone has a better idea.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • bump

  • This is what I did so far and it works almost perfect since I can only do it for a max amount of numbers. If I use more C2 can't handle the amount. So I would have to keep repeating this method. Maybe someone has a better idea.

    A sample capx would help us understand what you are doing and what you are trying to achieve.

    Are you trying to make a random map generator? If so, there are some good examples on the forums.

  • What I have is a grid of blocks. For example 6x7. So 42 blocks. Certain blocks I want to be grey. I use Id from the blocks to chose wich one. Different for each level. So I cannot place them manually since every level is on the same layout. What you see on screenshots above is the best solution I can think of. Thanks for helping.

  • You could use a string to store the values and use tokenat() to get at the different parts.

  • You could use a string to store the values and use tokenat() to get at the different parts.

    I am not familiar with using that function. I'll try to figuire out how it works. Thanks for your response

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