For Loop in Function at project start issue

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

    I'm new to Construct 2, coming from a C# background, and I spent an hour looking around the forums, but couldn't find someone with a similar problem as what I'm having. My project has a simple 1 dimensional number array of size 6 that at the project load I am trying to initialize with a function. Right now the code looks like this:

    System | On Loader Layout Complete

    -----arrayOfIntegers | Set Size to (6,0,0)

    -----Function        | Call "Set_Up_New_Game"()

    Function | On Set_Up_New_Game

    -----System | For "" from 0 to 6 | arrayOfIntegers | Set value at loopindex to 4

    When I stopped the project with the debugger at first opportunity after the condition ran, the data in the array is still set to its initial all zeroes. Needless to say I'm a bit puzzled.

    Things I've tried:

    -Moving the function before the Loader Layout condition

    -Changed the condition from "On Loader Layout Complete" to "On Start of Layout"

    Granted there do exist other items in both the starting condition's and the Function's action sections, but nothing directly related to that array (as far as I know). I can attach the project file upon request. Maybe there's something I just don't understand about how Construct 2 executes things...? Any advice would be appreciated, thanks in advance!

  • I just tried a very similar test, and you need to set size(6,1,1) - not with zeros.

    Also, set size(6,1,1) means you have 6 cells in the array numbered 0 to 5. Your "For" loop will run 7 times, so it should be For "" from 0 to 5

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi AllanR,

    Many thanks for the quick reply, I appreciate it. I took your suggestion and that fixed it, many thanks. I was under the impression setting the array to 6,1,1 would make a three dimensional array, but apparently it does not. Thanks also for pointing out the for loop is inclusive not exclusive on the limit. I'm sure these are all things I'll get used to with more practice using Construct 2. On to more joyous discoveries!

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