Like AlanR explained, loops in Construct are actually performed in one tick. If there is a Wait inside the loop, it doesn't pause loop execution, it creates a delayed thread. So a loop like this becomes infinite and will freeze the browser:
> While
stop=0
Wait 0
Set stop=1
And that's pretty much what I was doing. So the whole point of me doing it this way was the result of another thread I started:
construct.net/en/forum/construct-3/how-do-i-8/god-need-repeat-until-146195/page-2
In Delphi, there's a repeat:until loop which is a lot like a while. It keeps doing something until a condition is met. And, as in my case, if you're doing lengthy loops, there's an application.update you can plug in anywhere and the interface gets updated. This while, it's going to take some effort to convert.
I appreciate you guys giving me ideas and suggestions and it's apparent that I'm going to have to figure another way to do all of this without the while. All of the languages I've learned before Construct (except maybe Basic) have been function or procedure based and as little as possible goes on the main thread. And since I had this inside a function, running the timer or dt isn't going to be an easy fix.
Here's what I'm doing:
* On function 'CheckFresh'
| Local number T = 0
| Local number B = 0
| Local number R = 0
| Local number L = 0
| Local number dir = 0
----+ System: 0 is Number
-----> System: Set T to ArrayOffset-1
-----> System: Set B to ArrayHeight-ArrayOffset
-----> System: Set L to ArrayOffset-1
-----> System: Set R to ArrayWidth-ArrayOffset
-----> System: Set dir to 0
-----> Functions: Set return value 0
----+ System: While
--------+ System: T ≤ B
--------+ System: L ≤ R
------------+ System: dir = 3
----------------+ System: For "I" from B to T
--------------------+ TerrainArray: Value at (LoopIndex("I"), L, 0) = WaterTileFresh
------------------------+ System: Functions.CheckAllWater2(LoopIndex("I"),L,0) = 1
-------------------------> Functions: Set return value 1
-------------------------> System: Set FreshWaterX to LoopIndex("I")
-------------------------> System: Set FreshWaterY to L
----------------+ System: L is Number
-----------------> System: Add 1 to L
-----------------> System: Set dir to 0
------------+ System: Else
-------------> (no actions)
------------+ System: dir = 2
----------------+ System: For "I" from R to L
--------------------+ TerrainArray: Value at (B, LoopIndex("I"), 0) = WaterTileFresh
------------------------+ System: Functions.CheckAllWater2(B,LoopIndex("I"),0) = 1
-------------------------> Functions: Set return value 1
-------------------------> System: Set FreshWaterX to B
-------------------------> System: Set FreshWaterY to LoopIndex("I")
----------------+ System: B is Number
-----------------> System: Subtract 1 from B
-----------------> System: Set dir to 3
------------+ System: Else
-------------> (no actions)
------------+ System: dir = 1
----------------+ System: For "I" from T to B
--------------------+ TerrainArray: Value at (LoopIndex("I"), R, 0) = WaterTileFresh
------------------------+ System: Functions.CheckAllWater2(LoopIndex("I"),R,0) = 1
-------------------------> Functions: Set return value 1
-------------------------> System: Set FreshWaterX to LoopIndex("I")
-------------------------> System: Set FreshWaterY to R
----------------+ System: R is Number
-----------------> System: Subtract 1 from R
-----------------> System: Set dir to 2
------------+ System: Else
-------------> (no actions)
------------+ System: dir = 0
----------------+ System: For "I" from L to R
--------------------+ TerrainArray: Value at (T, LoopIndex("I"), 0) = WaterTileFresh
------------------------+ System: Functions.CheckAllWater2(T,LoopIndex("I"),0) = 1
-------------------------> Functions: Set return value 1
-------------------------> System: Set FreshWaterX to T
-------------------------> System: Set FreshWaterY to LoopIndex("I")
----------------+ System: T is Number
-----------------> System: Add 1 to T
-----------------> System: Set dir to 1
--------+ System: Else
---------> System: Stop loop
This is still with my current procedural terrain kick.
Basically, this loop starts at the top left corner of the array. It then reads across, down, left and up in a spiral fashion until it reaches the center of the array. It's purpose is to find a specific a number in the array (representing fresh water) then check all 8 surrounding elements to make sure they're the same. By spiraling inward, the last positive check it does will be the closest fresh water to the center. If it fails completely in finding any, it re initializes the array, and starts all over with a different one.