I am currently creating a single player game with levels in it. I have a list variable named Levels that keeps track of all the levels the player has beat (it also keeps track of how many moves the player used to beat the level). I've tried to set it up so that the game saves this list. The problem is I can't seem to get it to work and I don't know why. I've looked up a lot of resources and I think I'm doing it right, but its not working.
Can someone help me out, I don't know what the problem is, whether its saving incorrectly or loading incorrectly or something.
Code:
//Saving
var/Levels[120] //currently 120 levels
var/lvl //keeps track of the current level
turf/end
Entered(mob/player) //saves whenever player reaches end of level
if(!Levels[lvl] || player.moves < Levels[lvl]) //If this is the first time beating a level save it, or if you do it in less moves save the better moves.
Levels[lvl] = player.moves
player.Save()
mob/proc/save()
var/savefile/F = new()
Write(F)
client.Export(F)
mob/Write(savefile/F)
F.cd = "list"
for(var/v in Levels)
F<< v
F.cd = ".."
//loading
mob/Login()
..()
var/savefile/F = client.Import()
if(F) Read(F)
mob/Read(savefile/F)
var/v = null
F.cd = "list"
while(!F.eof)
F >> v
Levels += v
F.cd = ".."
I've done several variations of this code and none of them have seemed to work. I don't think the savefile is being exported correctly but honestly I'm not sure at all.
Thanks for any help in advance!