GMS 2 Question about possible future saving glitch


So my game saves with ini files storing variables in them. I noticed that sometimes when I create new objects gamemaker will automatically reorder the object numbers of each of my objects and it will mess up previous save files. For example, in my save file it has currentParty0 = 14, telling the game that the party member in the first slot is object number 14 which is currently the character Jeebo. However, if I add a new weapon into the game for example, it sometimes decides to reorganize the numbers and will make the object code for Jeebo 15 and then 14 will be the blank player object which will cause the game to crash since it tries to read variables which aren't in the blank player object because it's supposed to be the Jeebo object. I can manually go into the game save and just change the 14 to a 15 for currentParty0 and will fix this problem, however I will also need to change currentParty1 and 2 and also all of their inventories, etc. to their updated codes which usually is just one more than the previous if I added one new object. This isn't a huge deal now, but I plan on updating my game post-release and I can't have updates corrupting everyone's save files. My guess as to why it's happening is because the weapons are all children of the obj_Weapons object. I assume this would mean that they will have to be shoved up at the beginning of the list of objects since obj_Weapons is up there and the children must be with the parent. I'm not sure if this is true or not but it makes sense to me as most of the times where this problem occurs is when I add a new weapon or a new player character or something. I'm not sure though. Does anyone know a way around this?


Use object_get_name() when saving and asset_get_index() when loading to convert each ID to a string and back again.