First, two FOR loops are created, one for the X COORD and one for the Y COORD (Z COORD can be done as well for infinite terrains in ALL axes). In the last FOR loop, generate your chunks in there. The function 'CreateChunk( Vector )' is a function defined outside of the loop. All it does, is create the chunk entity, and set it's position according to what's in the Vector given. The reason for 'CreateChunk( Vector )' four times, is for radial generation (Where it generates around the current chunk.) This achieves Minecraft-esque chunks, where the first chunk is created for loading the game, and after the game loads, chunks around the player loads.
for x = 0, math.floor(RENDER_DISTANCE / 2) do
for y = 0, math.floor(RENDER_DISTANCE / 2) do
CreateChunk( Vector( self.Chunk.x + x, self.Chunk.y + y, 1) )
CreateChunk( Vector( self.Chunk.x - x, self.Chunk.y - y, 1) )
CreateChunk( Vector( self.Chunk.x - x, self.Chunk.y + y, 1) )
CreateChunk( Vector( self.Chunk.x + x, self.Chunk.y - y, 1) )
After ALL players are an X amount (where X is the size of the RENDER_DISTANCE halved * the chunk size) away from any chunk, it saves into a .txt file (currently saves the color and position ), and radially generates EVERY Player's current chunk (Saved to a NWString). From there, infinite-cy is attained.
There are... complications with this system.
First off, there's chunk errors, not much of a rarity (I hate fucking ponies...) in Minecraft. This can be created by using the PhysGun to move the chunk. I'm trying to patch this error, but it can happen.
Second, there's a VERY RARE chance of 'ED_Alloc: No Free Edicts' (Layman's Terms: Out of Memory). I'm implementing a limiter, where a maximum of 512 chunks (Entities cap is 2048) can exist in The Game (I lost...)
Third, performance, as it is an issue with Minecraft with too many chunks loaded. I would love to find alternative ways for a lot of performance-whoring actions, but there's not much. Only Think() and StartTouch() are the only performance whore processes, that I know of/are, that are being used.
Next on the agenda:
I plan on using structure generation (spawning homes here and there) based on a world seed, as well as saving EVERYTHING inside of the chunk. I have an idea on saving the contents of a chunk, it's not that hard.
Note: I rewritten this post, as most of the things I said have changed.