• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

collected items keep appearing in rooms after loading from save

hey all!
I've been working on a remake for Casper for the ps1, sega saturn, 3DO, etc. Im about 95% done. Im just hitting a snag with saving and loading from an INF file. All of my attributes and player position and current room I'm in saves. However, when I save the game and load from said save, I cant get the game to remember which items I've already collected (ie, which instances have been destroyed in a room, and which remain). All reload. Obviously this is a problem as opened doors and chests, etc, will also all re-appear. heres my script for saving:

save script (runs on pressing spacebar in the player object)
var file,inst_num,n0,n1,inst;
file=get_save_filename("save","Savefile.inf")
if (file_exists(file)) file_delete(file); //SAVES GAME/OVERWRITES

ini_open(file);
var saveroom = room;
inst_num = instance_number(saveinstance) ;//THIS IS A PARENT OBJECT- ITEMS ARE CHILDREN.
n0=0;
n1=0;
while inst_num >0{
inst = instance_find(saveinstance,inst_num-1)
ini_write_real("save",string(n0)+string(n1),inst.object_index);
n1+=1;
ini_write_real("save",string(n0)+string(n1),inst.x);
n1+=1;
ini_write_real("save",string(n0)+string(n1),inst.y);
inst_num-=1;
n0+=1;
n1=0;

}
ini_write_real("save","room",saveroom);
ini_write_real("save","brass keys",global.brasskeys);
ini_write_real("save","health points",health);
ini_write_real("save","gold coins",global.gold);
ini_write_real("save","iron keys",global.ironkeys);
ini_write_real("save","iron weights",global.ironweights);
ini_write_real("save","x location",player.x);
ini_write_real("save","y location",player.y);

HERE IS THE LOAD SCRIPT, runs from main menu by pressing load button and selecting save INF file when prompted;
var file,n0,n1,inst,xx,yy;
file = get_open_filename("save","Savefile.inf")
{
ini_open(file);
n0=0;
n1=0;
inst=0;
xx=0;
yy=0;
while ini_key_exists("save",string(n0)+string(n1)){
inst = ini_read_real("save",string(n0)+string(n1),0);
n1+=1;
xx = ini_read_real("save",string(n0)+string(n1),0);
n1+=1;
yy = ini_read_real("save",string(n0)+string(n1),0);
instance_create(xx,yy,inst);
n0+=1;
n1=0;
}
var LoadedRoom = ini_read_real("save","room",0)
global.brasskeys= ini_read_real("save","brass keys",0)
global.ironkeys= ini_read_real("save","iron keys",0)
global.gold= ini_read_real("save","gold coins",0)
health = ini_read_real("save"," health points",100)
global.ironweights = ini_read_real("save","iron weights",0)
player.x= ini_read_real("save","x location",0)
player.y= ini_read_real("save","y location",0)


ini_close();

room_goto(LoadedRoom);

audio_play_sound(gamerestored,0,false)
}




ini_close();
audio_play_sound(gamesaved,0,false)

and Ive uploaded a screenshot of the INF text file! I cant figure out whats wrong exactly. Any viable solutions would be greatly appreciated!
 

Attachments

Top