• 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!

GMS 2 Trouble saving ds_list with ini

Hello all!

I've been running across this problem all day and I still can't figure out why this is not working.
I'm trying to add a value to the list and then save it to an ini file. Problem is, it saves a value like "nan" or "inf".

And I'm only testing out to see if this will save values. I'm planning on the future for it to save weapons that you unlock.

Not sure if it's because I'm not understanding something properly or what :(
But here is what i'm doing.

Code:
var val;
ini_open("save.ini");
list = ds_list_create();
ds_list_add(list, 1);
val = ds_list_write(list);
ini_write_real("Lists", "0", val);
ds_list_clear(list);
ini_close();
Please let me know what I should do!
 

TheouAegis

Member
ds_list_write() returns a string, so val contains a string, not a real. As Catastrophe said, you need to use the correct ini_write_ derivative.
 
ds_list_write() returns a string, so val contains a string, not a real. As Catastrophe said, you need to use the correct ini_write_ derivative.
Is it possible to convert it to a number instead of having it write out as a string? Because what I want it to do is store the value of a sprite and then later load it up by retrieving the sprite value that I saved
 

Catastrophe

Member
ds_list_write I assume is simply compressing the data of the ds_list and uncompressing it. You shouldn't concern yourself with the value type it saves as. Think of it like a really old school NES password
 
ds_list_write I assume is simply compressing the data of the ds_list and uncompressing it. You shouldn't concern yourself with the value type it saves as. Think of it like a really old school NES password
I'm slowly catching on lol. So when I save all of it as ini_write_string, it gives me this: "2E0100000100000000000000000000000000F03F" which I assume is the number?
 
ds_list_write I assume is simply compressing the data of the ds_list and uncompressing it. You shouldn't concern yourself with the value type it saves as. Think of it like a really old school NES password
it's hard to tell because it pops as undefined when I try and read the value in game
 

Catastrophe

Member
That's the compressed value of the list. You then need to do ds_list_read() (check the manual on how to use it) with that string. The passed in newly created ds_list will then contain your number
 
That's the compressed value of the list. You then need to do ds_list_read() (check the manual on how to use it) with that string. The passed in newly created ds_list will then contain your number
It's not working very well with my system :( I just can't grasp it. Are there any other possible ways to save and load ds_lists? Possibly like saving a ds_list into a ds_map?
 

Catastrophe

Member
Erm, want to just show your code? It should be something like

val = ini_read_string(your stuff)
list = ds_list_create()
ds_list_read(list,val);
show_message("the value in the list is:" + string(ds_list_find_value(list,0)))

Show the save and load code.

The other way is to just loop the list and save values to a txt file, but this shouldn't be necessary
 
Top