ID:146398
 
Code:
var/savefile/SaveFile = new("players.sav")

mob/Write(savefile/F)
F["key"] << key
F["score"] << score
mob/Read(savefile/F)
F["key"] >> key
F["score"] >> score



mob/proc/savescore()
Write()
..()
mob/proc/readscore()
Read()
..()
</dm
</b>
<dm>


Problem description:
I am trying to very simply record a score, and then spit it back out by calling the proc later. Yes, I realize this is an ultra pathetic attempt. Please help!

Well, you're loading the score variable to the players 'gender' variable for starters.
In response to Nadrew
Hehehe

Alright, fixed that, what's next?
In response to Draxxis
When you call Write() and Read(), you don't pass a savefile as an argument. So put SaveFile there.
mob/proc/savescore()
var/savefile/F = new("players.sav") //Access the savefile
F["key"] << key //Write the info
F["score"] << score
mob/proc/readscore()
var/savefile/F = new("players.sav") //Access the savefile
F["key"] >> key //Read the info
F["score"] >> score


In response to DeathAwaitsU
Thank You wise one!
In response to DeathAwaitsU
I was wondering, how could I record more than one key to the savefile and the key's score, and then how would I figure out what score is highest, and spit out the top 10 of them?
In response to Draxxis
Look up a scoreboard demo.
In response to DeathAwaitsU
holy confusing...

didn't help.

I'm just too dumb for that one.
In response to Draxxis
In order to store them to one file, when ever you want the save to happen you should call a proc which creates/updates the savefile.

mob/var/score = 500

mob/verb/Savemyscore()
SaveScore(usr.score, usr.key)
usr << "Score saved"

proc/SaveScore(score, key)
var/savefile/F = new("highscores.scores")
var/list/currentdata = list()
F["scores"] >> currentdata //put everything already in the savefile to a list
if(currentdata.Find(key)) //if we used to be in the savefile
var/old = currentdata[key] //our old data
currentdata -= old //remove the old data so that it can be updates
var/list/mydata = list(key=score)
F["scores"] << mydata //add our data


I'm not sure but I assume something along those lines would be an approach. I don't know about spitting out the top 10.
In response to DeathAwaitsU
Well, thanks for your effort, I'm still confused, and I don't think that worked. I'm going to try to do some more searching and see if I can figure this out.