[Request] Condition "On loop finished"

Discussion and feedback on Construct 2

Post » Thu Aug 14, 2014 1:40 pm

Hi,

Some loops take longer then 1 tick to complete, therefore would like to request a condition "On Loop Finished".
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Thu Aug 14, 2014 2:16 pm

Which loops? All event-based loops finish synchronously in the same tick. There's no need for a condition for when they finished, because you can just put an event after it and that will run when the above loop finishes.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Thu Aug 14, 2014 2:44 pm

Ashley wrote:Which loops? All event-based loops finish synchronously in the same tick. There's no need for a condition for when they finished, because you can just put an event after it and that will run when the above loop finishes.


It's about system loops. They actually seam to take longer then one tick. I'm using 3 "For" loops, to loop trough 96x96x10 array. Takes about a second for results to appear. For now I'm used condition that checks if each loop has reached max field in array to trigger next stage. But in test from month ago, when I used condition that was adding 1 every tick, to change the states of the event's chain, I maybe managed to get dozen of rows with results and the rest was empty. Therefore I assumed it takes longer for loop to run then one tick. Maybe I'm doing it not the right way?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Thu Aug 14, 2014 4:25 pm

No, system loops always complete in the same tick. You must be making a mistake (or, probably very rarely, it's a bug) if it looks like it takes a few ticks to complete, that should never happen and would make loops far more difficult to use usefully.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Fri Aug 15, 2014 12:45 pm

Ashley wrote:No, system loops always complete in the same tick. You must be making a mistake (or, probably very rarely, it's a bug) if it looks like it takes a few ticks to complete, that should never happen and would make loops far more difficult to use usefully.


Maybe I've made a mistake. Have no way of checking now. But not so long ago I've seen other topic here with some people having same issue. If I encounter the issue again, will let you know. For now, I'm just switching variables at the end of loops.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Fri Aug 15, 2014 1:04 pm

If you make a very intensive loop, it can cause the game to freeze whilst it does its processing. This freeze means it is making sure that the entire loop completes in 1 tick, and when completed, it will go to the next tick and the game should unfreeze. If your game is not freezing when using big loops, then yeah that's pretty weird lol
B
51
S
20
G
10
Posts: 571
Reputation: 9,819

Post » Fri Aug 15, 2014 1:07 pm

I do think it's highly unlikely there is an engine bug here because the loops are very widely used and if there were any problems like you describe they would surely have turned up by now already.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Fri Aug 15, 2014 1:08 pm

Iterating 96*96*10 might take a little while.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Fri Aug 15, 2014 11:28 pm

Well, my original code from month ago was something like this

-State = 0
-- For "X" Loop, For "Y" loop --> do stuff on array
-- Set varState to 1

And it did only show up small percentage of the array results.

Since then I've came up with new solution, where if all For loop results are equal to all array dimensions, then change varState. And it's working

Also, this array processing is not an in game event, as it's a map generation chain, so it's ok to wait a bit. But I did made a version that could be run real time, for loop just going trough several rows per tick only, so it doesn't stop the game at all, if I'd want to use some massive array when doing an infinite world for example. Just a tip if anyone would want to know ^^
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
91
S
30
G
22
Posts: 1,985
Reputation: 20,149


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests