Array Looping issue

0 favourites
  • 3 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Hey all,

    I'm encountering a weird issue with a small project I'm working on and was hoping for some answers as to what's going on. Essentially my player goes through a set of trials (let's call it 5 trials) made up of x steps (let's call it 10 steps). As errors are accrued in performing each step they are tallied in an array. I currently use one array for all the trials and load them into a spreadsheet-style format of text objects. This part works perfectly.

    However, I want to tally the number of errors accrued in each trial, which is where the problems are starting. Currently I'm looping through the array 5 times (one time per trial) with the number of loops increasing by 10s (loop 10 times, 20 times etc.) and adding the array.at(loopindex-1) to a local variable for each trial (loop1, loop2 etc.), and then setting text for the tallies like so:

    set text trial 5: clamp((loop5-loop4),0,loop5)

    set text trial 4: clamp((loop4-loop3),0,loop4)

    etc.

    I can't figure out why this isn't working at all. It correctly tallies about 80% of the time and the other times it randomly drops or adds values of 1 per trial. It was doubling values per trial at one point but I added a "Once While True" value (though it only occurs "at start of layout") which fixed that issue.

    I'm thinking of just loading each trial into it's own array and going through this without a big looping tally system but I have to know why this isn't working regardless of what comes next lol. Am I missing some piece of theory or logic here??

    Thanks in advance for your help!!!!

  • Wait, you are using 1D array for this task?

    Change your array dimensions to 5x10. Here is a demo I made:

    https://www.dropbox.com/s/2ojwkuot5an8q ... .capx?dl=0

    Run the project in Debug Mode (ctrl-F4) to see array contents.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks dop2000 for your example! Your hep is very much appreciated!

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