• 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!

help with ds map

1213brett

Member
hi im trying to make a maze with corner tiles using bit masking I keep geeting this


Data structure with index does not exist.
at gml_Object_o_level_Create_0 (line 136) - _tile_index = ds_map_find_value(global.grid_,string(_tile_index))


I know I created a grid but it must not be a ds map can you please hep the code is below

var _wall_map_id = layer_tilemap_get_id("WallTiles");
var _floor_map_id = layer_tilemap_get_id("FloorTiles");

width_ = room_width div CELL_WIDTH;
height_ = room_height div CELL_HEIGHT;
global.grid_ = ds_grid_create(width_, height_);
grid_path = mp_grid_create(0,0,width_,height_,CELL_WIDTH,CELL_HEIGHT)
ds_grid_set_region(global.grid_, 0, 0, width_ - 1, height_ - 1, VOID);


tile_size = sprite_width;
var index,_north_tile,_south_tile,_west_tile,_east_tile,_north_east_tile,_north_west_tile,_south_east_tile,_south_west_tile,tile_size,tile_map;
size = 32

for (var _y = 1; _y < height_-1; _y++) {
for (var _x = 1; _x < width_-1; _x++) {
if (global.grid_[# _x, _y] != FLOOR) {
var _north_tile =global.grid_[# _x, _y-1] == VOID;
var _west_tile = global.grid_[# _x-1, _y] == VOID;
var _east_tile = global.grid_[# _x+1, _y] == VOID;
var _south_tile = global.grid_[# _x, _y+1] == VOID;
_north_west_tile = place_meeting(x-size,y-size,object_index) && _west_tile && _north_tile;
_north_east_tile = place_meeting(x+size,y-size,object_index) && _north_tile && _east_tile;
_south_west_tile = place_meeting(x-size,y+size,object_index) && _south_tile && _west_tile;
_south_east_tile = place_meeting(x+size,y+size,object_index) && _south_tile && _east_tile;

var _tile_index= _north_west_tile + 2*_north_tile + 4*_north_east_tile + 8*_west_tile + 16*_east_tile + 32*_south_west_tile + 64*_south_tile + 128*_south_east_tile
_tile_index = ds_map_find_value(global.grid_,string(_tile_index));

tilemap_set(_wall_map_id, _tile_index, _x, _y);

}
}
}
 

Tsa05

Member
You very literally successfully solved your own issue; you did create a grid and it is not a map.

These are 2 different types of structures. Use ds_grid_get() to find a value in a grid. Use ds_map_find_value to find a value in a map.
 
Top