Hanging issue with nesting loops
Hi team,
So, I have a very, very annoying problem.
I'm working on the army builder section for my current wip, which involves a lot of loops, many of which are cozily nested within each other. In a nutshell, the player can select from a range of units, they get values written to an array, then a series of loops runs through the array and moves data to a different array, and extrapolates and writes some additional values based on what is present.
Blah blah blah.
My problem is occurring when I'm expanding all this data to what it needs to look like in the game. When I click the button to execute it all, the following loops happen;
On Mission Select button clicked:
-> Start Loop "2 Player Local Start"
On Loop "2 Player Local Start"
-> Start Loop P1 Army (X) (where x is equal to a value based on which army the player selected, at the moment always 1)
On Loop "P1 Army 1
-> Activate Group [Orderguard Loops] (container to hold all the loops)
-> Start Loop "Orderguard Prewrite" 1 time
-> Start Loop "Orderguard Division Write" 5 times
-> Start Loop "Orderguard Unit Write" 5 times
-> Start Loop "P1 Array Shift" 100 times
-> Start Loop "Orderguard Unit Populate" 100 times
-> Start Loop "Orderguard Mob Populate" 1 time
-> Start Loop "Orderguard Special/Upgrade" 1 time
Briefly; Prewrite runs 5 different loops 20 times, that writes values 1-5 through a column in the InGame array.
Division Write runs a loop 20 times (so, 5x20=100) that copies a value from Pregame array to InGame array.
Unit Write does the same thing, with each of the 20 loops also running an additional loop another 20 times (2000 loops total), copying a Unit ID and up to 20 upgrade option ID's from Pregame array to InGame array.
P1 Array Shift moves all the data in InGame array to the left, occupying all the blank columns (100 loops, with each loop potentially running up to 99 times (10,000 loops)).
Orderguard Unit Populate runs 100x, writing values to the InGame array based on Unit ID's
Orderguard Mob Populate runs a loop 100x, which in turn runs a loop 20x, each of which runs another loop (4000 loops), writing values to cells based on the Loadout IDs already written in the Unit Write loops.
Orderguard Special/Upgrade runs loops that picks up other values prewritten in Unit Write, writing values to the InGame array using the same loop logic as Mob Populate.
Soooooooo. It was all working fine, until I was writing the 10th upgrade loop. Suddenly everything started hanging when I'd click the initial button to the start the loop, so, working backwards, I tried to figure out what I did that broke the loop logic. Everything looked fine. I then ran the Orderguard Special/Upgrade loop 0 times, trying to revert back to where it still worked, but alas, no luck, it still hangs.
Deleted the Orderguard Special/Upgrade loop, and all the conditions related, and it worked.
Started writing the Upgrade loops again, and it hangs again. Now, even after deleting the loops and the events pertaining to Special/Upgrade, it hangs, despite none of the seemingly problematic loops or events existing anymore. Fortunately I have a backup, so everything up to the Special/Upgrade section is working, but I'm afraid if I start adding more loops it will weirdly corrupt again.
TL:DR (skim the above paragraph hah)
So, is this a known bug? I had thought maybe I'm trying to do too much in a single frame, or giving the program too many loops to cycle through to fire the right one, but it was working fine until suddenly it didn't when I added a certain event, and it just seems odd that even deleting these events still causes the program to hang when I click the Mission Select button to fire it all.
Sorry the wall-o-text, but any idea where to start investigating this would be appreciated.