GML how to save and load the position "x,y" the player?

royer14

Member
Hello, in this question, I am working with ini files, so to save, I use:
Code:
ini_open("sav.ini");
ini_write_real("Posicion","X",obj_player.x);
ini_write_real("Posicion","Y",obj_player.y);
ini_close();
Now I need to clarify that I use a player object and I place it in each room.
So I do not know how to make the same player object, I guess in the
create event
Code:
ini_open("sav.ini");

var p_x = ini_read_real("Posicion","X",obj_player.x);
var p_y = ini_read_real("Posicion","Y",obj_player.y);
ini_close();
x = p_x;  //obj_player
y = p_y; //obj_player
But it turns out that this only works in the first room -> "room_St1",

I have these rooms:
  1. room_St1
  2. room_St2
  3. room_St3
  4. room_St4
I think the coordinates x and y are different in the rooms

 

PlayerOne

Member
Edit: After re-reading you should make a controller object and make it persistent then place the save code in an alarm or user_event function. That way you can execute the code when needed.
 
Last edited:
Top