var/savefile/F3 = new/savefile("savepoints.dat") // Loads the save points
var/SaveCount = 0
F3["SaveCount"] >> SaveCount
if(SaveCount)
for(var/N = 1;N<=SaveCount;N++)
var/X,Y,Z
var/obj/Misc/SavePoint/O = new()
F3["[N] x"] >> X
F3["[N] y"] >> Y
F3["[N] z"] >> Z
world << "[N] - [X],[Y],[Z]" //testing
O.loc = locate(X,Y,Z)
var/SaveCount = 0 // Saves the savepoints
var/savefile/F3 = new/savefile("savepoints.dat")
for(var/obj/Misc/SavePoint/O in world)
SaveCount++
F3["[SaveCount] x"] << O.x
F3["[SaveCount] y"] << O.y
F3["[SaveCount] z"] << O.z
world << "[SaveCount] - [O.x], [O.y], [O.z]" //testing
F3["SaveCount"] << SaveCount
Problem description:
I've never been all that great with save files. First off, the code compiles and seems to run just fine. I open the world, create a few savepoints and click a verb to save them (second piece of code). When I restart the world, for some reason the X variable for the first savepoint it loads goes missing (null), so that point vanishes from the map. Since the savepoint never makes it to the map, when the world is restarted again it ceases to exist (and therefore isn't saved). The cycle continues over and over as the world is loaded until all the savepoints have effectively disappeared.
Saving would then involve just saving the savepoints list itself, and loading would involve just writing F["savepoints"], though you'll get an (incorrect) warning about that, so you can instead do F["savepoints"] >> L, where L is just a throwaway list (don't load into the savepoints list itself, as the list will then contain duplicates).