GMS 2.3+ save the state of a randomly generated world?

some time back I created a game that featured a cave that randomly generated itself every time you left and came back, it was a crappy game but I want to make a game similar to terraria or that one obscure scuba flash game but I haven't been able to save my randomly generated worlds and reload them later so if anyone has any ideas on how to do that please do let me know!
 

FoxyOfJungle

Kazan Games
It depends on how you are generating the world, if you are using ds_grids, save the entire grid in a file (in the manual, there are some functions related to saving), it can be ds_maps or any other structure, it all depends on how you are generating these worlds... What do you do?
 
so basically I have a row of objects from top to bottom of the world and each of those objects is either some sort of block and or empty space that deletes blocks around it creating caves and such
 

TheouAegis

Member
If it's objects, you could just use a loop and write their object_index to a buffer then save that.

Code:
for(var row = 0; row < room_height; row += 16;) //or sprite_height
for(var col = 0; col < room_width; col += 16;) //or sprite_width
{
    var inst = instance_find(col,row,all);
    if inst buffer_write(save_buffer, buffer_u8, inst.object_index);
    else buffer_write(save_buffer,buffer_u8,noone);
}
buffer_write(save_buffer,buffer_u8,-1);
That final write isn't really needed, but maybe you'd have a use for it. When loading the room, use the same loop to get the coordinates to create instances of each object_index read from the buffer.
 
Top