C
Crispywrists
Guest
Hello!
So I've just got round to implementing a load and save feature, but it's giving me a bit of trouble.
I want it to remember my character's (obj_cliff) position and load that up, but whenever I load it it spawns at a random place. I mean if I press save somewhere then load it, it will always load it at that random place, so it is saving a position, just the wrong one...Then if I save it again in a different place it will load up at the new seemingly random location. Rest assured it is driving me mad.
Here's my save script:
Then my load script:
Is there any glaringly obvious faults? Because my inventory is playing up as well, but that may just be to do with how I've set it up (I admit it, I'm a noob), I'm not even sure I've got all my global variables in that save - but I tried removing all else apart from the basic position save / load functions and it still goes weird.
On a second note is there an easy way to view all global variables you have in your game to make sure they're saved?
Many thanks in advance and sorry for the long code.
Crisps.
So I've just got round to implementing a load and save feature, but it's giving me a bit of trouble.
I want it to remember my character's (obj_cliff) position and load that up, but whenever I load it it spawns at a random place. I mean if I press save somewhere then load it, it will always load it at that random place, so it is saving a position, just the wrong one...Then if I save it again in a different place it will load up at the new seemingly random location. Rest assured it is driving me mad.
Here's my save script:
if (file_exists("save"))file_delete("save");
ini_open("save");
var savedroom = room;
// The room
ini_write_real("save1","room",savedroom);
//Cliff's posish
ini_write_real("save1","position",obj_cliff.x);
ini_write_real("save1","position",obj_cliff.y);
// Inventory
ini_write_real("save1","inventory", global.inv);
ini_write_real("save1","inventory", global.key);
ini_write_real("save1","inventory", global.skateboard);
ini_write_real("save1","inventory", global.docmartens);
ini_write_real("save1","inventory", global.cash);
ini_write_real("save1","inventory", global.bones);
ini_write_real("save1","inventory", global.snacks);
ini_write_real("save1","inventory", global.phone);
//Others
ini_write_real("save1","others", global.cool);
ini_write_real("save1","others", global.scenehappened);
ini_write_real("save1","others", global.rimesley);
//Bowling backroom
ini_write_real("save1","others", global.bowling);
ini_close();
ini_open("save");
var savedroom = room;
// The room
ini_write_real("save1","room",savedroom);
//Cliff's posish
ini_write_real("save1","position",obj_cliff.x);
ini_write_real("save1","position",obj_cliff.y);
// Inventory
ini_write_real("save1","inventory", global.inv);
ini_write_real("save1","inventory", global.key);
ini_write_real("save1","inventory", global.skateboard);
ini_write_real("save1","inventory", global.docmartens);
ini_write_real("save1","inventory", global.cash);
ini_write_real("save1","inventory", global.bones);
ini_write_real("save1","inventory", global.snacks);
ini_write_real("save1","inventory", global.phone);
//Others
ini_write_real("save1","others", global.cool);
ini_write_real("save1","others", global.scenehappened);
ini_write_real("save1","others", global.rimesley);
//Bowling backroom
ini_write_real("save1","others", global.bowling);
ini_close();
Then my load script:
if (file_exists("save"))
{
ini_open("save");
var loadedroom = ini_read_real("save1","room",rm_initialize);
//Cliff's position
obj_cliff.x = ini_read_real("save1","position",-1);
obj_cliff.y = ini_read_real("save1","position",-1);
//Inventory
global.inv = ini_read_real("save1","inventory",0);
global.key = ini_read_real("save1","inventory",0);
global.skateboard = ini_read_real("save1","inventory",0);
global.docmartens = ini_read_real("save1","inventory",0);
global.cash = ini_read_real("save1","inventory",0);
global.bones = ini_read_real("save1","inventory",0);
global.snacks = ini_read_real("save1","inventory",0);
global.phone = ini_read_real("save1","inventory",0);
//Others
global.cool = ini_read_real("save1","others",0);
global.scenehappened = ini_read_real("save1","others",0);
global.rimesley = ini_read_real("save1","others",0);
global.bowling = ini_read_real("save1","others",0);
room_goto(loadedroom);
}
{
ini_open("save");
var loadedroom = ini_read_real("save1","room",rm_initialize);
//Cliff's position
obj_cliff.x = ini_read_real("save1","position",-1);
obj_cliff.y = ini_read_real("save1","position",-1);
//Inventory
global.inv = ini_read_real("save1","inventory",0);
global.key = ini_read_real("save1","inventory",0);
global.skateboard = ini_read_real("save1","inventory",0);
global.docmartens = ini_read_real("save1","inventory",0);
global.cash = ini_read_real("save1","inventory",0);
global.bones = ini_read_real("save1","inventory",0);
global.snacks = ini_read_real("save1","inventory",0);
global.phone = ini_read_real("save1","inventory",0);
//Others
global.cool = ini_read_real("save1","others",0);
global.scenehappened = ini_read_real("save1","others",0);
global.rimesley = ini_read_real("save1","others",0);
global.bowling = ini_read_real("save1","others",0);
room_goto(loadedroom);
}
Is there any glaringly obvious faults? Because my inventory is playing up as well, but that may just be to do with how I've set it up (I admit it, I'm a noob), I'm not even sure I've got all my global variables in that save - but I tried removing all else apart from the basic position save / load functions and it still goes weird.
On a second note is there an easy way to view all global variables you have in your game to make sure they're saved?
Many thanks in advance and sorry for the long code.
Crisps.