What I would do in your situation (i.e. not having to change a lot, and fix the problem):
- Instead of calling a function that starts the while loop, keep that loop in a separate Group (default: inactive). So, instead of calling the function, just make the Group active.
- Instead of using While loop, use simple conditions (if conditions). That way you can have your 0.1 wait and update progress timely as everything else progresses in the game. Won't get stuck. No while loops.
- Make the group Inactive at the end of that loop, or when progress bar has reached end.
This technique makes the most sense, thanks. But I'd still have to shoehorn the while into it. As I mentioned before, I'm reading an array in a spiral. In the code above t=top b=bottom l=left & r=right and represents which row or column it's looking at. As each loop finishes it either adds one to top or left or it subtracts one from from bottom or right. The reason I use a while is so that it keep running until top <= bottom and left <= right.
I could do recursion but I spent so much time rearranging this so that c3 likes it that I'm loathe to dive into that pit again. I may just leave it without a progress update. This one only takes 1-3 seconds which isn't bad. The next one takes longer but it's much more susceptible to being broken up into chunks.
Here, let me show you guys what I'm doing and maybe your brains will come up with a better solution than I have.
I'm creating procedural maps. The light blue represents fresh water, dark blue salt water. I want the character to start as close to the center of the map as possible and have fresh water nearby. The while loop starts at the top left of the array that makes this map and spirals inward. The last x,y coordinates it finds with viable fresh water is saved so that from there, I can do another search for a spot for the character to start.
I could have spiraled outward from the center and found the fresh water sooner but the logic of figuring that out hurt my head. Either way, I was looking at using a while.
You can barely see it, but there's a green dot on the fresh water real close to the center of the map. That's the x,y coordinates the loop finds.