P
powernoel
Guest
Hi everyone!
I have been using Game Maker Studio Pro (1) for a bit long now, and after reading lots of thread here's my first one!
I'm coding a save system for my game. I use a ini file system, with an [object] section to store the amount of each object the player has while saving.
During the game, the amount of each item is stored in "obj_cursor" in a 2D list.
For exemple, getting 10 "saphir" (wich is indexed by 5), is stored in obj_cursor.loot[5,0]
Here's how I load the save : obj_cursor.loot[5,0]=ini_read_real("objets","saphir",0)
And how I save : ini_write_real("objets","saphir",obj_cursor.loot[5,0])
When I manually edit the .ini in the local storage (getting 20 saphir for exemple), I have my 20 saphir in my bag when the game launch and during the whole game. But when I save, the new ini file set [objets] "saphir" to 0.
It's really strange because the x and y coordonate of my character, which are saved too, are workng well.
By coding a debug message, I've seen that when my room start, obj_cursor[5,0] is equal to 0 and then 10 (I have two lines of degug while having one line of debug's code).
Here's the full saving system:
if file_exists("rockman.sav")
{
file_delete("rockman.sav")
}
ini_open("rockman.sav")
ini_write_real("position","x",obj_player_world.x)
ini_write_real("position","y",obj_player_world.y)
ini_write_real("objets","saphir",obj_cursor.loot[5,0])
ini_close()
And the full loading system:
if file_exists("rockman.sav")
{
ini_open("rockman.sav")
x=ini_read_real("position","x",x)
y=ini_read_real("position","y",y)
obj_cursor.loot[5,0]=ini_read_real("objets","saphir",0)
ini_close()
}
I hope you'll help me as you helped the other threads I've been reading all this time!
And sorry for the english, I'm French. Feel free to correct me if I wrote grammatical mistakes, it helps me too ^^"
I have been using Game Maker Studio Pro (1) for a bit long now, and after reading lots of thread here's my first one!
I'm coding a save system for my game. I use a ini file system, with an [object] section to store the amount of each object the player has while saving.
During the game, the amount of each item is stored in "obj_cursor" in a 2D list.
For exemple, getting 10 "saphir" (wich is indexed by 5), is stored in obj_cursor.loot[5,0]
Here's how I load the save : obj_cursor.loot[5,0]=ini_read_real("objets","saphir",0)
And how I save : ini_write_real("objets","saphir",obj_cursor.loot[5,0])
When I manually edit the .ini in the local storage (getting 20 saphir for exemple), I have my 20 saphir in my bag when the game launch and during the whole game. But when I save, the new ini file set [objets] "saphir" to 0.
It's really strange because the x and y coordonate of my character, which are saved too, are workng well.
By coding a debug message, I've seen that when my room start, obj_cursor[5,0] is equal to 0 and then 10 (I have two lines of degug while having one line of debug's code).
Here's the full saving system:
if file_exists("rockman.sav")
{
file_delete("rockman.sav")
}
ini_open("rockman.sav")
ini_write_real("position","x",obj_player_world.x)
ini_write_real("position","y",obj_player_world.y)
ini_write_real("objets","saphir",obj_cursor.loot[5,0])
ini_close()
And the full loading system:
if file_exists("rockman.sav")
{
ini_open("rockman.sav")
x=ini_read_real("position","x",x)
y=ini_read_real("position","y",y)
obj_cursor.loot[5,0]=ini_read_real("objets","saphir",0)
ini_close()
}
I hope you'll help me as you helped the other threads I've been reading all this time!
And sorry for the english, I'm French. Feel free to correct me if I wrote grammatical mistakes, it helps me too ^^"
Last edited by a moderator: