Adds a previously created ds_list to a given ds_map.


GML Code Example

ds_map_add_list(id, key, value)

Argument Description
id The id of the map to use.
key The key for the added list.
value The id of the list to add.

Returns: N/A


With this function you can assign a (previously created) ds_list to a key within the given ds_map. This function is designed for creating JSON compatible maps which you would then encode using json_encode and should only be used in conjunction with that functionality. If a ds_map has a list added in this way, destroying the parent map will also destroy the contained lists and free their memory.


GML Code Example

var j_list = ds_list_create();
 ds_list_add(j_list, health);
 ds_list_add(j_list, lives);
 ds_list_add(j_list, score);
 var j_map = ds_map_create();
 ds_map_add_list(j_map, "list", j_list);
 var j = json_encode(j_map);

The above code will create a list and populate it with the various values of global variables. This list is then "nested" within a ds_map, and the map is then encoded into a JSON string, before the map is destroyed, removing it, and any lists it contains, from memory.

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