BUG:Nested loopindexes with the same loopindex variables

Bugs will be moved here once resolved.

Post » Sun Aug 16, 2015 6:57 pm

Problem Description
If you nest loops and use the same loopindex, even if it is in a seperate function, it does not work correctly. In the example below, replacing the second "a" with a "c" causes it to loop four times rather than eight. This can be problematical if writing effective code functions in C2 - discovered this when I had nested loops with "xi", but the two loops with index "xi" were in completely different files.

Attach a Capx

Image

Description of Capx
Three nested loops with duplicate loopindexes (loopindices ?)

Steps to Reproduce Bug
  • Step 1 : Run the above code

Observed Result

1,11,0
1,12,0
2,11,0
2,12,0

(from Browser log window)

Expected Result

Should be 8 outputs not 4. Or should warn about reusage. I'm hazarding a guess that loopindex is stored in a java hash in the runtime ? Maybe the loopindex value could be set to nil when the loop exits and if there is a loopindex already present when a loop is started causes a RTX ?

Affected Browsers
  • Chrome: (YES)

Operating System and Service Pack
Windows 10

Construct 2 Version ID
v206 64 bit
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Mon Aug 17, 2015 1:50 pm

Thanks, good catch. Should be fixed in the next build. Note for me it did loop the correct number of times; it is just that the Chrome dev tools log would collapse identical logs in to one line with a number next to it. The issue was loopindex("a") was returning the least nested loop's index (event 2) rather than the most nested (event 4). From the next build, when identical loop names are used it returns the most nested first, which fixes it.
Scirra Founder
B
397
S
236
G
88
Posts: 24,427
Reputation: 194,568


Return to Closed bugs

Who is online

Users browsing this forum: MadSpy and 3 guests