Saving issues

Yizzard

Member
Hi I'm trying to make a saving mechanism in my game, and all of the single real number values are working fine with the ini_write_real() function, but when I try to use ds_lists to save arrays, it saves completely the wrong values and I can't figure out why. The loading works correctly, because the actual saving is just plain saving the wrong values, and once loaded it loads the same incorrect values. For reference, the global.currentParty array holds object references to different character objects (1 is the main character Jeebo, 2 is his cousin Jerbo, ect.)

Code:
ini_open("Save.sav");
var savedRoom = room;

var curParty = ds_list_create();
var cnt;
var test;
for(cnt = 0; cnt < array_length_1d(global.currentParty); cnt++)
{
    test = global.currentParty[cnt];
    ds_list_add(curParty, test);
    show_debug_message(ds_list_find_index(curParty, cnt));
    show_debug_message(ds_list_find_value(curParty, test));
}
ini_write_string("Save1", "curPar", ds_list_write(curParty));
ds_list_destroy(curParty);
this is just the top part of the code as I save a lot of variables and the code is over 100 lines long, but every ds_list saves incorrect values while all straight up ini_write_real values (for example later on I have an ini_write_real("Save1", "room", savedRoom) that saves the room, works correctly. I put these debug messages on here to see what exactly it was saving and here was the output:

-1
undefined
0
undefined
1
undefined

The actual values that were stored in test were 1, 2, and 3. (which I ran the debugger and confirmed each run through) Obviously the ds_list_add is not adding the values correctly. Does anyone know why this is?
 
H

Homunculus

Guest
ds_list_find_value takes the position (index) as argument and returns the value at that index, but you are passing the party value instead. ds_list_find_index takes a value and returns the index (if the value is found), but you are passing an index.

In short, you probably misunderstood or simply switched the arguments you pass to those functions.
 

Yizzard

Member
Oh wow lol you're right, I just had them switched. I believe everything is working properly again. Thanks!
 
Top