M
Mooner01
Guest
Hello all
I am running GML in GMS2 with runtime version 2.3.0.401 and IDE version 2.3.0.529
I am trying to generate a room on startup that is filled with obj_grass objects. I know, I should use tiles, but that is a problem for later. The code creates the appropriate layers and then tries to place the grass in those layers, but when I call instance_create_layer, it errors out because the layer doesn't exist. Code is below. In the file structure it is contained in a script called 'startup.gml'.
I am getting this error:
I've tried creating a new room, but that hasn't worked. When I run in debug mode, the layers variable evaluates to -1, which makes me think that the layers aren't being made. Any ideas?
I am running GML in GMS2 with runtime version 2.3.0.401 and IDE version 2.3.0.529
I am trying to generate a room on startup that is filled with obj_grass objects. I know, I should use tiles, but that is a problem for later. The code creates the appropriate layers and then tries to place the grass in those layers, but when I call instance_create_layer, it errors out because the layer doesn't exist. Code is below. In the file structure it is contained in a script called 'startup.gml'.
GML:
outside_width_px = 1280
outside_height_px = 960
room_set_height(room, outside_height_px)
room_set_width(room, outside_width_px)
terrain = layer_create(100, "terrain")
layer_create(0, "vegetation")
layer_create(-100, "entities")
layer_create(-150, "player")
layers = layer_get_all() // for debug
current = room_get_name(room) // debug
hor_tiles = outside_width_px / tile_size // tile_size = 32, stored in a macro elsewhere
ver_tiles = outside_height_px / tile_size
for(i = 0; i < hor_tiles; i++) {
for(j = 0; j < ver_tiles; j++) {
instance_create_layer(i * tile_size, j * tile_size, "terrain", obj_grass)
}
}
Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object <undefined>:
instance_create_layer :: specified layer "terrain" does not exist
at gml_GlobalScript_Startup (line 16) - instance_create_layer(i * tile_size, j * tile_size, "terrain", obj_grass)
############################################################################################
gml_GlobalScript_Startup (line 16)