For Loop in Function at project start issue

Get help using Construct 2

Post » Thu Jan 16, 2014 2:58 am

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!
B
3
Posts: 4
Reputation: 183

Post » Thu Jan 16, 2014 3:41 pm

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
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Thu Jan 16, 2014 9:18 pm

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!
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher, ketramtu18, Syazanie Amirin, XMatrix and 7 guests