• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Saving and loading object templates

A

AnimusRex

Guest
So I'm trying to save all the types and locations of instances in my design room, where I design parts of a level, to be created randomly in the main game.

My design room, to help visualize;


I want to go through this room, read the column, row, and what type of basic block it is, then be able to call this in the main game, but populate it with real block types.

Here's my code as it is right now;

Code:
//Adding array values
for(i = 0; i < array_length_1d(instance_id); i+=1)

block = (instance_id[i]).block
xspot = (instance_id[i]).x
yspot = (instance_id[i]).y

ds_grid_draw(blockgrid, 16, 16)  //Supposed to draw grid values, not working
So how do I know if it's actually collecting the data? I first tried to do this using a ds_grid,

but abandoned it after learning of instance_id[], but haven't been able to get it working.
 
W

whale_cancer

Guest
What the heck is ds_grid_draw? I don't see it in the manual, is it a custom script of yours?

array_length_1d(instance_id);
Are you sure this array has the appropriate length?

I would include a debugging message in your for loop so you can have a log of what is going on. E.g.:

Code:
show_debug_message("Adding object at "+string(xspot)+','+string(yspot)+' with value +string('block'))
...or some such.

Edit: Also, why isn't your code for the loop bracketed?
 
A

AnimusRex

Guest
ds_grid_draw is a custom script, yes. The array should just be the number of objects in the room, should it not? Isn't that how instance_id works?

Not sure why it wasn't bracketed, fixed.

EDIT:

using
Code:
show_debug_message("Adding object at "+string(xspot)+','+string(yspot)+' with value '+string(block))
just says that xspot and yspot and block aren't defined variables.
 
Last edited by a moderator:
W

whale_cancer

Guest
Hmmmm, is it your bracket placement? Should (instance_id).y be instance_id.y? I am unsure if that makes a difference.

If xspot and yspot aren't being defined than the problem occurs before your custom draw script. Nothing else jumps out at me.
 
A

AnimusRex

Guest
Hmmmm, is it your bracket placement? Should (instance_id).y be instance_id.y? I am unsure if that makes a difference.

If xspot and yspot aren't being defined than the problem occurs before your custom draw script. Nothing else jumps out at me.
Removed the brackets, no difference, still saying xspot and yspot aren't defined. Why they aren't, I don't know.
 
W

whale_cancer

Guest
show_debug_message(string(array_length_1d(instance_id))) returns 0 for me in a room with instances. That seems to be your problem.

Edit: just use for(i = 0; i <instance_count; i+=1) instead. Worked for me.
 
A

AnimusRex

Guest
Code:
// Create Grid
blockgrid = ds_grid_create(width, height)

//Adding grid values
for (var i = 0; i < width*height; i++)
{
    x += blocksize * i
    if x >= blocksize*width
    {x -= blocksize*width
    y += blocksize}
    if collision_point(x, y, obj_block1, 0, 1)
        {ds_grid_add(blockgrid, x div blocksize, y div blocksize, 1)}
    if collision_point(x, y, obj_block2, 0, 1)
        {ds_grid_set(blockgrid, x div blocksize, y div blocksize, 2)}
    if collision_point(x, y, obj_block3, 0, 1)
        {ds_grid_add(blockgrid, x div blocksize, y div blocksize, 3)}
}
Would something like this work?

I know next to nothing about how to debug; how would I check if this is saving the values into the grid?
 
W

whale_cancer

Guest
Code:
// Create Grid
blockgrid = ds_grid_create(width, height)

//Adding grid values
for (var i = 0; i < width*height; i++)
{
    x += blocksize * i
    if x >= blocksize*width
    {x -= blocksize*width
    y += blocksize}
    if collision_point(x, y, obj_block1, 0, 1)
        {ds_grid_add(blockgrid, x div blocksize, y div blocksize, 1)}
    if collision_point(x, y, obj_block2, 0, 1)
        {ds_grid_set(blockgrid, x div blocksize, y div blocksize, 2)}
    if collision_point(x, y, obj_block3, 0, 1)
        {ds_grid_add(blockgrid, x div blocksize, y div blocksize, 3)}
}
Would something like this work?

I know next to nothing about how to debug; how would I check if this is saving the values into the grid?
That is some extremely messy stuff going on, and I am not clear on what you are trying to do. You posted at the same time as me, so you may have missed my last post where I got your code to work in a test project. You should be able to just use that.
 

Bingdom

Googledom
I have a save/load script for something like this, the only thing you have to do is create a room, run this script and save it. Save File will be saved %localappdata%/Ships
This is ripped from one of my projects.

SCR_Save
Code:
///SCR_Save(name);
i = 0;
name = argument0;
//Count the amount of times it will have to save and keep the number to know how many times to load
count = instance_number(OBJ_Build);

if file_exists(working_directory + "\Ships\" + string(name) + ".ini") {
file_delete(working_directory + "\Ships\" + string(name) + ".ini")
}

savefile = ini_open(working_directory + "\Ships\" + string(name) + ".ini")
//Save the amount of parts, so we know how many times to load
savefile = ini_write_real("Parts","Amount",count);
i = count;
//Repeat the amount of parts available, then save them under their i name
    repeat(count+1) {
    with instance_find(OBJ_Build,i) {
    other.savefile = ini_write_real(string(other.i),"y",y);
    other.savefile = ini_write_real(string(other.i),"x",x);
    }
    i -= 1;
    }
ini_close();
For the loading
SCR_Load
Code:
///SCR_Load(name)
name = argument0
if file_exists(working_directory + "\Ships\" + string(name) + ".ini") {
ini_open(working_directory + "\Ships\" + string(name) + ".ini")
load_count = ini_read_real("Parts","Amount",0);
loadi = load_count-1;
repeat(load_count) {
    with instance_create(x,y,OBJ_Build) {
    y = ini_read_real(string(other.loadi),"y",0);
    x = ini_read_real(string(other.loadi),"x",0);
    }
    loadi -= 1;
    }
ini_close();
} else show_message(string(name) + " Does not exist");
You're welcome ;)

Just change the OBJ_Build to the objects you are using.
 
A

AnimusRex

Guest
Sorry bingdom, I don't think this will work for what I'm using it for. It's not influenced by the person playing the game at all, and in the room are various island templates in 10x20 grids of 32x32 cells, I want to be able to call on this arrangement of items to spawn blocks in my procedural generation. I'm not really understanding what your code does, but I don't think it's the same really.

Whale, I'm not sure how you got it working, it's still telling me block, spotx, and spoty aren't defined.

Code:
//Adding array values
for(i = 0; i < instance_count; i+=1)

block = instance_id[i].block
xspot = instance_id[i].x
yspot = instance_id[i].y

show_debug_message("Adding object at "+string(xspot)+','+string(yspot)+' with value '+string(block))

is the code I have.

It tells me I have no instance at instance_id[-4].

Not sure how it's getting to -4, but I set it to i < instance_count-4 to get it to run, and there's no debug message being shown anywhere. Where am I supposed to be seeing this?
 
Last edited by a moderator:

Bingdom

Googledom
What it does is saves the x and y coordinates of every block in the room into a ini file. What you need to do is put 1 design into the room, then run the save script. The save will be located at %localappdata%/Ships and inside that will store all of the blocks x and y coordinates. The load script can be run during gameplay which will spawn all of those blocks into the room, in the same arrangement of how you saved the ship.

So basically this is the process
You make a ship (x,y)
Save First block at 0,0
Save Second block at 32,0
Save Third block at 32,32
Save Fourth block at 0,32

Incase you couldnt tell, its a 2x2 block sized object

Then this information is saved into a ini file.

Then when you use the load script with the name specified, it will load objects like this
Spawn First block at 0,0
Spawn Second block at 32,0
Spawn Third block at 32,32
Spawn Fourth block at 0,32

Hopefully this clears up what my code does. ;)
 
A

AnimusRex

Guest
Yes, but I'm dealing with hundreds of blocks, all different values, and I don't really want to save them as an external file... I don't know what most of your script is doing.
 

Bingdom

Googledom
Ahh ok, my method would be more used for allowing the user to design and create ships.

You're using the arrays wrong, you should be doing this:
Code:
//Adding array values
for(i = 0; i < instance_number(obj_block); i+=1) {
find = instance_find(obj_block,i);
block[i] = find.id;
xspot[i] = find.x;
yspot[i] = find.y;
}
 
A

AnimusRex

Guest
How do I check that it's saving the arrangement of blocks? The debug message gives me an error that it cant find xspot, or it just doesn't display the message anywhere.
edit;
also, looking at your code, I have multiple different place holder blocks that I want to give different values to spawn different blocks in the game, not just one object in the design room.
 

Bingdom

Googledom
You haven't assigned which part of the array it should read from, do this:
show_debug_message("Adding object at "+string(xspot[ i ])+','+string(yspot[ i ])+' with id '+string(block[ i ])

Edit:
For some reason i cannot do [ i ] without the spaces
 
A

AnimusRex

Guest
Okay, I think that's working, for obj_block1, anyway; how would I create a section of this from the array? Like actually spawn a group of objects based on it? It is printing the debug message, but I can't really tell if it's working as it's essentially a lot of out-of-place numbers.
 

Bingdom

Googledom
You will need to look at this.

Once you understand how this works, you will need to put it into a loop and do a very similar process to the one i provided to you.

Edit:
BTW, i noticed block[ i ] is not needed
 
A

AnimusRex

Guest
Why is the block not needed? I want to save what type of object it is to spawn the correct object upon the generation script, no?

EDIT:

So I'm getting it working. Sort of.

using;

Code:
for(i = 0; i < 20; i+=1)
{
instance_create(xspot[i]+64, yspot[i]+64, obj_block)
}
I can create i number of objects based on the templates. A few problems arise: how would I define it to be based on the "grid" in the array? Like, in my room, there's not the same number of blocks in each 20x10 cell, so this method as I have it doesn't work properly. How would I limit it to a specific area?

As well, I tried using it with multiple types of blocks using
Code:
for(i = 0; i < instance_number(obj_block1); i+=1) {
find = instance_find(obj_block1,i);
block[i] = find.id;
xspot[i] = find.x;
yspot[i] = find.y;
}

for(j = 0; j < instance_number(obj_block2); j+=1) {
find = instance_find(obj_block2,j);
block[j] = find.id;
xspot[j] = find.x;
yspot[j] = find.y;
}

for(h = 0; h < instance_number(obj_block3); h+=1) {
find = instance_find(obj_block3,h);
block[h] = find.id;
xspot[h] = find.x;
yspot[h] = find.y;
}

for(i = 0; i < 150; i+=1)
{
instance_create(xspot[i]+64, yspot[i]+64, obj_block)
}

for(h = 0; h < 150; h+=1)
{
instance_create(xspot[h]+64, yspot[h]+64, obj_50block)
}

for(j = 0; j < 150; j+=1)
{
instance_create(xspot[j]+64, yspot[j]+64, obj_bramble)
}
Which totally broke the room; seemingly random blocks everywhere.
 
Last edited by a moderator:

Bingdom

Googledom
Instance ID changes every time, every time you spawn in a new object, it will go up by 1. Every instance has a unique ID.
You still can get the amount of objects to spawn using array_length_1d(xspot) or yspot.
 
Last edited:

Bingdom

Googledom
block[ j ] and block[ i ] has absolutely no difference.

j and i are just numbers, exactly like in algebra.

You should do this instead for each individual ship.
xspot_a[ i ]
yspot_a[ i ]

xspot_b[ i ]
yspot_b[ i ]

xspot_c[ i ]
yspot_c[ i ]

For the loading, like i said before, use array_length_1d(xspot_a) :)

for(i = 0; i < array_length_1d(xspot_a); i+=1)
{
instance_create(xspot_a[ i ]+64, yspot_a[ i ]+64, obj_block)
}

You can see there is no use of block[ i ] ;)
 
Last edited:
A

AnimusRex

Guest
This code;
Code:
for(i = 0; i < array_length_1d(xspot_a); i+=1)
just loads all the objects in the array; I want to load them based on their coordinates.

Referring to that first picture, on the grid each slot is 20 cells wide by 10 cells high, how would I load just those cells?

Should I name the cells in that grid for easy reference in terms of loading them procedurally?
 
Last edited by a moderator:

Bingdom

Googledom
You need to create an offset for when you are creating the objects. For example,
for(i = 0; i < array_length_1d(xspot_a); i+=1)
{
instance_create(xspot_a[ i ]+mouse_x, yspot_a[ i ]+mouse_y, obj_block)
}
Will spawn a ship according to your mouse's position. You can see that i added the current mouse coordinate relative to the xspot and yspot.

Also, i have already renamed the variables to xspot_a, xspot_b, xspot_c. This is how you can differentiate between ships, or you can give them names if it makes it easier for you. ;)
 
A

AnimusRex

Guest
But then I'm going to have to do this entire block of code;

Code:
for(i = 0; i < array_length_1d(obj_arraycontroller.xspot_1); i+=1)
{
instance_create(obj_arraycontroller.xspot_1[i]+64, obj_arraycontroller.yspot_1[i]+64, obj_block)
}

for(i = 0; i < array_length_1d(obj_arraycontroller.xspot_2); i+=1)
{
instance_create(obj_arraycontroller.xspot_2[i]+64, obj_arraycontroller.yspot_2[i]+64, obj_50block)
}

for(i = 0; i < array_length_1d(obj_arraycontroller.xspot_3); i+=1)
{
instance_create(obj_arraycontroller.xspot_3[i]+64, obj_arraycontroller.yspot_3[i]+64, obj_bramble)
}
Just to spawn three different types of blocks on a tiny island. Isn't there a way to store what type of object it is and convert it somehow, rather than manually, and spawning all the blocks separately?

This is going to get quickly out of hand if I have different types of blocks, and I need to spawn 10+ random islands to make a level.

Also; I still don't see how I could spawn the instances further into the grid. As it always starts with the same area, the top left most blocks in the room, as it's looping from the number of instances counted with the array_length_1d, so no matter what xspot or yspot values I use, it's spawning the first blocks it encountered in the design room, just spawning the first island at a different location.

The main problem I'm noticing with this is that it's spawning based on the block number. Ie, I'm saying spawn X number of this type of block, when what I want to do is say spawn (this entire cell of blocks) based on the design room. There's not the same number of blocks in each cell, and doing this manually would be stupid.
 
Last edited by a moderator:
E

Efrik

Guest
I am a newbie as well. But I just finished an exercise about saving information in a way similar to yours.

Considering that you have created a room with a grid of smaller rooms, or chunks as I will call them, each containing a smaller grid of different objects, to be picked later by the game, I would create a 2D array whith important values in every column like Chunk reference // object type // X position inside the chunk // Y position inside the chunk
You can make a loop for every object in the room and save information of that object into the Array. One line for every object.
Or you could make a scan of the entire room, saving the objects in the room once found.
The chunk reference part can be saved so that when you call back a chunk you just have to call the items that specifically have that value in the array.

For calculating the chunk reference I would use something like this:

Chunk_X = object.x div chunk_width
Chunk_Y = object.y div chunk_height
// I am considering all chunks the same size

That would give you a coordinate refering the row and column of chunks in your room (the "div" statement is like a division, but excludes the decimal part, leaving an entire number).
Then you can count the X/Y location inside the chunk as the module (the rest left by the division) as

X_in_Chunk = object.x mod chunk_width
Y_in_Chunk = object.y mod chunk_height

Save these for values of every object in the array. Use the Chunk_X/Chunk_Y as reference to every chunk (although I prefer Chunk_ref=Chunk_Y*ColumnsOfChunks(3)+Chunk_X, so it becomes one and only number) once you call a random chunk, and then X_in_Chunk/Y_in_Chunk to set the object exactly in place.

Then you can save in a fith column the object type. You can use object_get_name (object_id) to save it as a string, resulting in "obj_block1", "obj_block2" or "obj_block3". You can later use asset_get_index (object_name_saved_in_the_array) to call it back and create it.

edit: fixed a formula up there
 
Last edited by a moderator:
A

AnimusRex

Guest
What's the difference between a 2D array and a grid, used in this context?

As it is, I'm finding a grid is a lot easier to visualize; I'm just not sure how to spawn the objects saved in it.
Code:
blocksize = 32
var width = room_width div blocksize; //Getting the number of columns
var height = room_height div blocksize; //Getting the number of rows

for (var i = 0; i < width*height; i++)  //Goes through the whole rooms columns and rows
{
    x += blocksize * i //Moves the controller object 32 pixels times each loop iteration

    if x >= blocksize*width //If the X value gets outside the number of columns,

    {x -= blocksize*width //Set the X value to zero, and

    y += blocksize} //Add one for the Y value, moving down to the next row

    if collision_point(x, y, obj_block1, 0, 1) //Checking each collision point to see what type of object is there, and save it in the respective cell in the grid
        {ds_grid_set(blockgrid, x div blocksize, y div blocksize, 1)}

    if collision_point(x, y, obj_block2, 0, 1) //This should work, should it not?
        {ds_grid_set(blockgrid, x div blocksize, y div blocksize, 2)}

    if collision_point(x, y, obj_block3, 0, 1)
        {ds_grid_set(blockgrid, x div blocksize, y div blocksize, 3)}
}
I don't understand why this seems really messy to some people; is there a way to call on a region of the grid using a loop and populate items based on the grid values?

I'm trying right now to use something along the lines of;

Code:
for(i = 40; i < ds_grid_value_exists(obj_arraycontroller.blockgrid, 0, 0, 20, 10, 1); i+=1) //Arbitrary number of loop times, just trying to pull from 0, 0, to 20, 10, ie one chunk
{
instance_create(obj_arraycontroller.blockgrid[# x, y], obj_arraycontroller.blockgrid[# x, y], obj_block) //This is where I'm confused; how do I use an accessor to find the coordinates?
}
 
E

Efrik

Guest
I guess 2D arrays and grids are more or less the same in this specific case. Use the one you prefer. GM´s manual says this about grids: "A ds_grid is basically a type of two-dimensional array."

Also, I would create a parent object called obj_block, making all kind of blocks its children, so that you dont have to check collision over every type of block, just over obj_block. Once collided save the block type with object_get_name in the array/grid. This would save you a lot of code if you had like 1200 different blocks.

Try something like this:


for (var i = 0; i < width*height; i++) //Goes through the whole rooms columns and rows
{
x += blocksize * i //Moves the controller object 32 pixels times each loop iteration

if x >= blocksize*width //If the X value gets outside the number of columns,

{x -= blocksize*width //Set the X value to zero, and

y += blocksize} //Add one for the Y value, moving down to the next row

blockgrid_number = (y div (room_height/6))*3+(x div (room_width/3)) //This will create a ref number to the piece of room of the grid to be saved, in your case the room is divided into 3x6 smaller rooms, numbered from 0 to 17
blockgrid_name= "blockgrid"+blockgrid_number //This gives a name to the grid so that every smaller room gets its own grid

if collision_point(x,y,obj_block,0,1) {
ds_grid_set(blockgrid_name,x mod (room_width/3), y mod (room_height/6), object_get_name(other)) //instead of a reference number you save the name of the object. But be careful as it is saved as a string
} else {
ds_grid_set(blockgrid_name,x mod (room_width/3), y mod (room_height/6), "0") //this gives a value to the emty cells
}
}


This way you create 17 different grids, each one representing a part of the bigger room. The information stored is the content of every cell.
I would save the information as the position of every object though. So many lines in the grid as objects in the room, with smaller room reference, object type (name), x and y stored in every collumn. My method would save space in rooms with few objects, yours would be better in case of many objects. I suppose it is a matter of tastes how to save it.
 
A

AnimusRex

Guest
Hey Efrik, it's telling me that
Code:
blockgrid_name= "blockgrid" + blockgrid_number
is an illegal addition, just wondering what specifically the blockgrid name and blockgrid number you have are doing
 
E

Efrik

Guest
Thats to make a unique name for every saved grid. But Im afraid i missed something. Try this:

Blockgrid_name="blockgrid"+string_format(blockgrid_number,2,0)

The string format function converts a value into string. It has given me problems in the past because it fills the empty ciphers with blanks, so be carefull when using it.

That code should result in names like "blockgrid 1", blockgrid 5", "blockgrid10", "blockgrid17"
 
E

Efrik

Guest
Btw,
There would be a "blockgrid " for blackgrid_number =0 and i dont know how GM works with blanks in names. It may cause problems. Maybe you can substitute these blanks with zeroes. Three is a function for that, although i dont remember it right now.
 
A

AnimusRex

Guest
So why don't I just use the blockgrid number and never use the blockgrid_name, it just seems like a step of added complexity; knowing that something is 0, or blockgrid 0 doesn't seem to matter, does it?

Under this model, how would I load these values and populate objects based on it?

Is there any easy way to debug and check the values in a grid? I don't even know that it's scanning the room properly, or how I would check?
 
E

Efrik

Guest
Do you want to create an object named "1"? My proposal is to create one grid for each chunk but you can add all objects in one and only grid, of course, adding a new column with the numerical referente, of course. One object can be easier to handle, but It would take more memory when working with it. It is up to you how to manage your information.

Calling the room back would be more or less the same, but backwards. I do not know the exact conditions of the calling. I have not yet studied procedural mapping. You can try this:

Room_number = irandom(17) //irandom returns a whole number, in our case it is the reference to the chunk

For (i=0;i<grid_height;i++) {
If (ds_grid_get(grid_name,i,ref_column)=Room_number) { //this filters the objects in the grid that correspond to the chunk we want to summon. It implies that all objects are in the same grid, as you want it.

if ds_grid_get(grid_name,i,name_ref_column)!=0, //Remember that we saved the object name or a "0" in case the cell was empty? Well, if the cell has to be empty we should summon nothing. that´s what this line is for.

Instance_create(
ds_grid_get(grid_name,i,x_ref_column), //the X coordinate from the correspondent column
ds_grid_get[grid_name,i,y_ref_column), //the same with the Y
asset_get_name (ds_grid_get(grid_name,i,name_ref_column))§ //This shall return the object stored as a string in the grid, in the column that you specified to store object names
)

}}}
 
A

AnimusRex

Guest
asset_get_name isn't a command in GML, I also don't know how why you're calling room_number, this all takes place in one room. I'm not sure what you mean by "calling the room back", either.
 
E

Efrik

Guest
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.
 
Top