ID:157771
 
I Have Made my first game but when we close the game the stats get refreshed.

I wanted to know how to make a save/load system for my games.

I would Appreciate the help.

:-)
mob/proc
Save()
if(src.z==2) return //we dont want to save them at the title screens!
var/savefile/F = new("Players/[src.key].sav") //creates a new savefile or overwrites an old one
F["Boss1"]<<src.Boss1
F["Music"]<<src.Music
F["LastX"]<<src.x
F["LastY"]<<src.y
F["LastZ"]<<src.z
F["dir"]<<src.dir
F["name"]<<src.name
F["icon_state"]<<src.icon_state
F["Level"]<<src.Level
F["Str"]<<src.Str
F["Def"]<<src.Def
F["MaxHP"]<<src.MaxHP
F["MaxMP"]<<src.MaxMP
F["Exp"]<<src.Exp
F["Nexp"]<<src.Nexp
F["Gold"]<<src.Gold
F["BankedGold"]<<src.BankedGold
F["Class"]<<src.Class
F["contents"]<<src.contents
F["Items"]<<src.Items
src<<"Game Saved"
This is from the RPG Maker Demo(with a few extra things as well of course. it is saved by manually saving every variable. The loading is practically the same, except you use >> instead of <<.
In response to Gamekrazzy
I would recommend saving the mob itself - much faster.

client proc save
var/savefile/S = new("X.sav")
S["mob"] << src.mob


client load
S [mob] >> src.mob

Use your head how to make that work.

If you have some variables that you do not want saved, define that variable as a temp.
mob/var
hp
xp
sp
jp
up
tmp/pu
haha
client
New()
Load()
..()
Del()
Save()
..()
proc
Save()
var/savefile/F = new("[key].save")
F["mob"] << mob
Load()
if(fexists("[key].save"))
var/savefile/F = new("[key].save")
F["mob"] >> mob

mob
/* Any special handling for saving and loading goes in mob/Write() and mob/Read() */
Write(var/savefile/F)
..()
//save our location
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
//load our location
var/turf/T = locate(F["x"], F["y"], F["z"])
if(T)
loc = T
In response to Garthor
Garthor what happened to your...figure it out yourself policy?
hmm
In response to Tabishi
There's nothing wrong with helping slightly with saves when it's an issue alot of people muck up eventually. It's not like he gave him the fully working 100% super save system, it's simple and meant to show him how to do it right.
In response to Tabishi
Tabishi wrote:
Garthor what happened to your...figure it out yourself policy?

There is an overwhelming amount of Doing It Wrong when it comes to savefiles.