GMS 2.3+ Creating objects stored inside of a ds_grid into a large room

Is there a way to create objects into a room that are stored inside of a ds_grid?

Instance_create_layer or depth doesn't like when I try and place a something other than a direct object and gives me an error.
I can draw my ds_grid when I have sprites stored in the draw event, but I imagine when I draw_sprite of objects in my ds_grid that just the sprite of an object is created but the object itself isn't created.

Thanks for any and all feedback.
-side note I had a much more lengthy post here but I'm editing it now because I want to simply ask the main question I have and ask more later if I need to.

Update below:
I am able to use instance_create_layer and in place of where I would put an object value I am able to place one ds_grid cell there that stores an object and create it. I just wonder why I am unable to use a for loop and instance create all the objects stored in all my cells..Screenshot (918).png
 
Last edited:

samspade

Member
I am able to use instance_create_layer and in place of where I would put an object value I am able to place one ds_grid cell there that stores an object and create it. I just wonder why I am unable to use a for loop and instance create all the objects stored in all my cells..
You can. Although it would need to be a double for loop. For example:

GML:
for (var i = 0; i < width; i += 1) {
    for (var j = 0; j < height; j += 1) {
        //do a thing with grid[# j, i]
    }
}
While it's a little different, as he is creating a map editor and representing the tiles purely with data rather than instances, you can see a good example of this in the following tutorial around the 3:30 mark (although I would recommend watching the whole thing as it might give you some ideas):

 
Top