Reads the map data structure from a string.


GML Code Example

ds_map_read(id, str [, legacy]);

Argument Description
id The id of the data structure to read the string into
str The string to read
legacy (optional) Can be either true or false or omitted completely.

Returns: N/A.


This function will take a string that has previously been created by the function ds_map_write and then read it into a previously created ds_map. If the map that the string is being read into contains any key/value pairs, these will be cleared first before the saved map is re-constructed. 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.


GML Code Example

inventory = ds_map_create();
 var t_string = ini_read_string("Saved", "0", "");
 if t_string != ""
    ds_map_read(inventory, t_string);

The above code creates a new ds_map and stores its id index in the variable "inventory". It then opens an ini file and reads a string from that file into the temporary variable "t_string". Finally, it checks to make sure that the string is valid (not the default ini value of "") and if it is it then reads the string into the newly created ds_map before closing the ini again.

Back: DS Maps

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here