Arrays kind of broken?

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • The project I'm currently working on seems to be having issues with the simplest tasks involving arrays and calculating values inside them.

    Something as simple as this (and what I recall has always worked flawlessly so far) doesn't work for some reason:

    calculate 5 values and put the sum into an specific array position. However, only the first value in that equation is taken into consideration. So, if say, all values are 500, the sum will be 500. If I change the first value to 1000, the sum will be 1000. Other values are simply not considered at all.

    Yet another issue. The first block works properly, just adding pre-determined values instead of fetching them from other array cells seems to work. However, in the following two blocks you can see that I needed to introduce variables because that is the only way it works. If I have values of, say, 10 in array cells I need to fetch for this equation, it will refuse to calculate them properly. But if I take an extra step and make that value of 10 via an variable, and calculate it that way, it works.

    But then, the last two blocks just flat-out work, even though nothing would indicate that would be the case seeing the previous issues.

    Any thoughts on why this happens? Is it possible that one of the updates screwed up array behavior, because I have stared way too much into my event sheets and just don't see any reasons why they should behave like this?

  • Feels like your array is storing string values instead of numbers. Or perhaps the size is wrong.

    Can you add an action "Array -> Download" and post the result, for both affected arrays?

  • Some values stored in the .json files were indeed categorized as strings, seeing how they were between quotation marks. So seeing how these values are inserted via TextInput, I suppose it automatically treats any text input as strings, even though the type is strictly set to "number".

    Therefore I guess the workaround is to put the text input into a variable first, and then proceed with calculations and stuff...or is there something I'm missing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use float(), and probably make a separate condition with "?" expression that checks if it is float or string.

  • even though the type is strictly set to "number"

    Textbox always stores text, no matter what type you set.

    To convert to numbers use int(Textbox.text) or float(Textbox.text)

  • The type for text input is for the purpose of determining the layout of the soft keyboard that opens by default iirc.

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