You are right, the function is "asset_get_index". My misstake, as I was writing on the road.
Room_number is actually a reference to the part of the room you have copied in the grid.
I still prefer saving the items as rows in an array. why? because by leaving the amount of columns free you can easily add more information about every single block, like health, transparecy, if it can be crossed (secret passages?), etc, something impossible if the information is stored as a copy of the map.
With this in mind here is my suggestion.
First, make all blocks children from an object called obj_block.
I am using spr_block as a sprite with the exact measure of a block.
Also, I assume that the room that you are going to copy is completely filled with blocks
Saving:
cl_ch=3 //columns of chunks, in your case, 3
rw_ch=6 //rows of chuncks, in your case, 6
// this helps because we are going to make a sub-grid of the grid, where every slot in the same area has the same value, this is, the sub-grid cell or piece of room it belongs to.
rm_cl=room_width/sprite_get_width(spr_block) //whide of cells in the whole room, also, number of columns
rm_rw=room_height/sprite_get_height(spr_block) //height of cells in the whole room, also, number of rows
// this is the complete room grid. It will be transformed as we want to know the position of cells in every piece of room or chunk
ch_cl=rm_wd/cl_ch //cells per chunk, width, or columns/chunk
ch_rw=rm_hg/rw_ch //cells per chunk, height or rows/chunk
for (i=0;i<rm_rw;i++) {
for (j=0;j<rm_cl,j++) { //For every row and column in the whole room
cl_ch_num=j div cl_ch //what chunks it is in, width or column
rw_ch_num=i div rw_ch //what chunk it is in, height or row
ch_num=rw_ch_num*cl_ch+cl_ch_num //chunk ref number [line it is in*cells/line+column it is in]
cl_rm_num=i mod cl_ch //what column it is inside the chunk
rw_rm_num= j mod rw_ch //what row it is inside the chunk
rm_num= i*rm_cl+j //Unique position ref number. the refers to the position of the cell inside the ROOM, not the chunk [line it is in*(cells/room)/(chunks/room)+column it is in]
object=instance_position(i*sprite_get_width(spr_block),j*sprite_get_height(spr_block),obj_block) //saving the object ID of the cell
if object != noone { //we are not saving empty cells
array_cells [rm_num,0]=ch_num; //chunk ref number
array_cells [rm_num,1]=cl_rm_num: //x position
array_cells [rm_num,2]=rw_rm_num; //y position
array_cells [i*j,3]= object_get_name(object) //this saves the name fo the object, not the ID, as a string
}
}}
And now for summoning the room from an (xO,yO) Original spot:
ch_num=irandom (cl_ch*rw_ch-1) //the chunk it is going to be summoned
for (k=0;k<rm_cl*rm_rw;k++) { //for every posible block saved in array_cells
Object=asset_get_index (array_cells[k,3]) //this saves an ID for the object saved in the array, if there is any
if array_cells[k,0]=ch_num { //if the chunk ref number of the scanned row in array_cells is the same we are summoning
instance_create(
xO+array_cells[k,1], //origin spot+x position inside the chunk
yO+array_cells[k,2], //oirigin spot + y position inside the chunk
Object //the object to be created, by name, not ID
)
}
}
I have not tested it, but I think it should work, although it saves the grid in a different distribution as you pretended to use.
I may have missspelled something or misstaken columns for rows somewhere, so read twice and be careful.