Need help with an array/map

Alright so I have a grid system that works fine and until recently I did not notice it has a fundamental flaw that is not an issue until I have more than 500 rows in the X direction.

The issue is in this function below that creates the initial array.

I know it’s 100% in this part of the logic because I even loaded just this function and printed out the length of the map and it does not add up to how many should be in there.
Example: if I have 100 Grid Size X and 100 Grid Size Y the length will be 10,000 as expected but when ever I have a Row X of higher than 500 it will not add up or maybe its rewriting the same index I am not sure but

If I set the Size of X and Y to 1000 each for example I should have a Map length of 1,000,000 but instead It gets a map length of 249,000.

I can’t seem to figure out what is causing this.

Now I know this isn’t exactly an array, but I did test it with an array instead of a map with the same logic and got the same result.

You can try going into Project Settings and searching for ‘Maximum Loop Iteration Count’ and set it to a high number like 5000000. But I’m thinking you would get an error message if this was actually the reason.

Either increase the loop count as suggested by @miyagi1 or, alternatively, do not generate it all in a single Tick…

Generate 10% wait .1s, generate next 10% and so on.

what would be the best way to do a loop in percentages? how would I interrupt the loop to load in chunks?

You wouldn’t interrupt the loop. You’d run smaller loops several times. Pseudo-script:

Adding 1000 ints over a span of 1s (100 elements every .1s). This way you can have other world generating timers running on different intervals.

Were you to build an entire game world in one single loooooop, the application would freeze / crash; surely.