GML Write ds_map to ini file, Read ds_map from ini file

How do I write a ds_map into an ini file and then reassemble the map from an ini file's contents so I can use it in game? The actual ini values should be difficult to edit ds_map gibberish. How do I put it back together as a ds_map in game, so I can check the individual key values, and set them accordingly.
 

Tsa05

Member
var data = json_encode(mapName);
ini_open("yourFile.ini");
ini_write_string("someSection", "someKey", data);
ini_close();


ini_open("yourFile.ini");
var data = ini_read_string("someSection", "someKey", "");
ini_close();
mapName = json_decode(data);
 
var data = json_encode(mapName);
ini_open("yourFile.ini");
ini_write_string("someSection", "someKey", data);
ini_close();


ini_open("yourFile.ini");
var data = ini_read_string("someSection", "someKey", "");
ini_close();
mapName = json_decode(data);
Does decode return a whole map or just 1 entry? Might work for my GM Studio projects, but it doesn't look like GM8 has json_encode, or base64_encode(). Does that make saving a map to ini in encrypted state impossible in GM8 projects, or is there a second way to do it in GM8?
 

Tsa05

Member
It re-builds the entire data structure for you with every last key and list restored into the map.
GameMaker 8, though?!! Ummm. Well.

Does GM8 have ds_map_write()? I can't remember when that was added.
If so, you can do data=ds_map_write(mapNape) and then write the map to an ini key.
You can read it back in and use ds_map_read(data) to re-create the map.

Note that this will only encode key-value pairs.
GameMaker 8 *definitely* didn't have the ability to nest lists or maps inside of maps.
 
It re-builds the entire data structure for you with every last key and list restored into the map.
GameMaker 8, though?!! Ummm. Well.

Does GM8 have ds_map_write()? I can't remember when that was added.
If so, you can do data=ds_map_write(mapNape) and then write the map to an ini key.
You can read it back in and use ds_map_read(data) to re-create the map.

Note that this will only encode key-value pairs.
GameMaker 8 *definitely* didn't have the ability to nest lists or maps inside of maps.
GM8 does have ds_map_write() and ds_map_read(). Can I save a ds_map in one write to the ini file, or do I need to read and write for every single item in the map individually? It's not a nested map just a series of entries like a list of items and values.
 
Top