• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Data Structures [Solved]


I apologize now for such a general topic, however I could really use some clarification. Ive read over the GM:S manual on DS lists, grids and maps a few times.

Ive just started to use ds_lists in my project and I see how useful it is to be able to write them to files etc. That being said, I dont understand the difference between ds_maps and ds_grids -- I'm looking for a simple explanation of when to use them, and why!

Any information is much appreciated!


Forum Staff
Imagine a grid like a 2D array with easier ways to manipulate held data.

Imagine a map like a 1D array that uses strings ("keys") to identify cells ("pairs") instead of 0-based 1-incrementing integers.

You use both according to these situations - depending on whether you need to access two-dimensional data via ID numbers or one-dimensional data via keys.


You can if you store lists inside maps.
var map = ds_map_create();
ds_map_add_list(map, "ones", ds_list_create());
ds_map_add_list(map, "twos", ds_list_create());
var ones = map[? "ones"];
ds_list_add(ones, 1, 11, 111);
var twos = map[? "twos"];
ds_list_add(twos, 2, 22, 222);