Really bogus reading from array issue [SOLVED!]

This forum is currently in read-only mode.
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Alright, I'm almost just about to give up on construct. There are a lot of neat features, but there are some basic logical aspects that are just plain broken. I'm probably going to have to come back when it gets its crap together. Anyways, I wonder if anyone can shed some light on this issue and perhaps save the day.

    I've got an array filled with values. I can load the file and load in the variables, and it's just fine, the correct numbers always come up, and it's spot on. I have an event that says "when a value is equal to zero" and "when a value is less than a value on an array" then it does stuff.

    It doesn't. I tried changing the "when a value is less than a value on an array" to "when a value is less than a value (which is the exact same number that comes up with the array)" and it works. I tried loading the value on the array to a separate value, and that still doesn't work. The event will not run.

    This engine took me 15 minutes to write, test and perfect in MMF2, I've been working on this same simple concept in Construct for an entire week. It literally consists of 8 lines of code. The only reason I would keep at Construct is the fact that I can make a product that is visually superior with "less effort", but really there are some neat features in Construct that require little effort, but there defiantly are still a few things that really need work, and I'd say they are pretty important. So I'll give it one more chance.

  • Post a cap, or a screen. Its kinda hard to tell from your description.

    I will say if your using "for each" on the array it may give you issues if your using a z.

  • <img src="http://dl.dropbox.com/u/16909290/ss.png">

    It's not an interfering piece of code, simply because there is not other code. All I want to do is grab a value from an array. It grabs the value, I can clearly see in the debug and if I input it to a string that it is the correct number, and that the other number is lower than it. But it just seems that anything grabbed from an array is rendered useless.

  • Still kind of hard to figure out what you want to happen.

    I can tell you I was able to grab data from my array "Array(3, Sprite.Value('an#'))", after I set it.

    Just wondering, you do know that two conditionals in the same line are treated like "and"?

    So if one is not true the event is skipped.

  • Yes, I do know that.

    Basically, when that first value reaches zero, and that second value hasn't passed a certain value, then it resets the first value and adds one to the second value. Basically, it adds to a counter with a variable speed.

    I was able to grab data from it too, but the data is useless. For instance, I place the number 284 into the array, load it into construct and it clearly says "yeah, I got 284" but it doesn't register that it is 284. If I simply just plug in 284 or place another variable that doesn't draw it's value from an array, then it functions perfectly fine, the first value counts down and when it reaches 0 it adds one to the second value and repeats until that second value equals 284.

  • Perhaps its an int() issue

    How often does your variable actually equal 0?

    Not 0.1, or less than zero, or perhaps even str()

  • it never has anything to do with floats, it's always an integer. The other thing I just thought of is that the array contains both strings and numbers. I know in MMF2 you have to choose either of the two (I usually choose text and just convert any values). Does a construct array have any of those restrictions? It still would be very odd that it would still return the correct value. Other than that, I'm stumped.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • From what I see here it's hard to tell what the issue is. For example, all the pv, are they text or number pv? Do they get mixed up? If you accidentally store a number as text, you will see the number in the debugger, but you can't compare it to a number as it is a text then, etc.

    Also:

    it never has anything to do with floats, it's always an integer.

    This isn't true. The fact that you use whole numbers doesn't make them integers. All numbers in Construct are always floats, and floats can get imprecise even when just calculating with whole numbers. That's due to the structure of floats.

    But that's vague. Can't tell more without actually seeing a cap. Couldn't you setup a demonstration cap? Would help solving this.

  • [quote:vccy17n5]Does a construct array have any of those restrictions?

    That I don't know, but you can always use int(), or str() applied to what you retrieve from your array to be sure.

    Other than that, I don't know what to tell you... frame rate issue?

  • [quote:11c71dkz]Does a construct array have any of those restrictions?

    That I don't know, but you can always use int(), or str() applied to what you retrieve from your array to be sure.

    Other than that, I don't know what to tell you... frame rate issue?

    You may store text and numbers mixed in an array. Every array "cell" keeps the information if the data is a number or a text ([Array: Set index 1 to 20] stores the number 20, [Array: Set index 2 to "20"] stores the text "20")

    EDIT: When running without debugger the result of 2 * Array(2) is 2 instead of 40, because multiplying the text is an error and therefore the text is treated as nothing.

  • the int() was the issue. without that, it thought the number was text, even though it was showing a number.

    I am really glad because I was attempting to recreate this in MMF2, and while i had the animation engine perfect, creating something like an 8 directions movement is just trouble. Sorry for getting so frustrated everyone, and thanks for the help, I really appreciate it. So if anyone else has an issue like this (using mixed arrays), just tell them to convert just to be sure.

    [quote:1x95mh6c]This isn't true. The fact that you use whole numbers doesn't make them integers. All numbers in Construct are always floats, and floats can get imprecise even when just calculating with whole numbers. That's due to the structure of floats.

    That's what I meant, I just was an idiot with my terms.

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