Data structuresThis functionality is only available in the Standard Edition of GameMaker.
In games you often need to store information. For example you need to store lists of items that a person carries or you want to store places that still need to be visited. You can use the arrays for this. But if you want to do more complicated operations, like sorting the data or searching for a particular item, you need to write large pieces of GML code which can be slow to execute.
To remedy this, GameMaker has a number of built-in data structures that can be accessed through functions. At the moment there are six different types of data structure available: stacks, queues, lists, maps, priority queues, and grids. Each of these data structures is tuned for a particular type of use (see below).
All data structures work globally in the same way. You can create a data structure with a function that returns an id for the structures. You use this id to perform operations on the data structures. Once you are done you destroy the data structure again to save storage. You can use as many of the structures at the same moment as you want. All structure can store both strings and real values.
Please note that data structures and their content are not saved when you save the game using the actions or functions for that. If you use data structures and want to allow for saves you have to create your own mechanism for that.
When comparing values, for example when searching in a map or sorting a list, GameMaker must decide when two values are equal. For strings and integer values this is clear but for real numbers, due to round-off errors, equal number can easily become unequal. For example (5/3)*3 will not be equal to 5. To avoid this, a precision is used. When the difference between two numbers is smaller than this precision they are considered equal. Default a precision of 0.0000001 is used. You can change this precision using the following function:
ds_set_precision(prec) Sets the precision used for comparisons.
This precision is used in all data structures but not in other comparisons in GML!
Information on data structures can be found in the following pages: