Reads the grid data structure from a string.


ds_grid_read(index, string [, legacy]);

Argument Description
index The index of the grid to read.
string The string to read into the ds_grid.
legacy (optional) Can be either true or false or omitted completely.

Returns: N/A


This function can be used to convert a string which has been created previously by the function ds_grid_write() back into a ds_grid. The ds_grid must have been created previously (see the example below). Note that if the data structure was created with previous versions of GameMaker you should add the optional argument "legacy", setting it to true as the string format has changed with this version.


grid = ds_grid_create(room_width div 32, room_height div 32);
ds_grid_read(grid, ini_read_string("Save", "0", ""));

The above code creates a ds_grid based on the size of the room (each 32x32 square of pixels represents one grid cell) and then reads a previously saved set of grid data from an ini file into the new ds grid.

Back: DS Grids
Next: ds_grid_write
© Copyright YoYo Games Ltd. 2018 All Rights Reserved