ID:1329130
 
(See the best response by MasterSpectra.)
I recently changed my Save/Load procs and now the new Load isn't working properly.

Code:
mob
proc
Save()
src << "Saving..."
if(fexists("Saves/Players/[src.ckey].sav"))
fdel("Saves/Players/[src.ckey].sav")
var/savefile/F = new("Saves/Players/[src.ckey].sav")

F["name"] << name

F["strength"] << strength
F["defense"] << defense
F["hpMax"] << hpMax
F["hp"] << hp

F["level"] << level
F["exp"] << exp
F["nextExp"] << nextExp

F["souls"] << souls

F["lastX"] << x
F["lastY"] << y
F["lastZ"] << z

F["contents"] << contents

F["race"] << race
F["iState"] << icon_state

F["macros"] << macros

F["verbs"] << verbs

F["coolManager"] << coolM

F["hair"] << hair
F["hairColor"] << hairColor

src << "Game Saved."
return 1

Load()
src << "Loading..."
if(fexists("Saves/Players/[src.ckey].sav"))
var
savefile/F = new("Saves/Players/[src.ckey].sav")
srcx
srcy
srcz
allVerbs
var/mob/player/pl = src
pl.transform(F["race"],F["iState"])

F["name"] >> name

F["strength"] >> strength
F["defense"] >> defense
F["hpMax"] >> hpMax
F["hp"] >> hp

F["level"] >> level
F["exp"] >> exp
F["nextExp"] >> nextExp

F["souls"] >> souls

F["lastX"] >> srcx
F["lastY"] >> srcy
F["lastZ"] >> srcz

F["contents"] >> contents
for(var/obj/getAble/equipAble/o in contents)
if(o.equipped)
_unequip(o)
_equip(o)

F["macros"] >> macros
refreshMacros()

F["verbs"] >> allVerbs
for(var/verb/v in allVerbs)
verbs += v

src << "OK"
F["coolManager"] >> coolM
coolM.update(src)
src << "OK2"

unfreeze()
loc = locate(srcx, srcy, srcz)

src << "Game Loaded."
return 1

else
src << "You do not have a character."
return 0


I think I need to show the CooldownManager code too:
CooldownManager
var
list/cooldowns = list()
mob/owner
New(mob/m)
owner = m
spawn()
loop()

proc
loop()
while(src && owner)
sleep(world.tick_lag)
for(var/Cooldown/c in cooldowns.Copy())
c.add(world.tick_lag)

create(name,delay)
cooldowns += new/Cooldown(name, delay)
has(name)
for(var/Cooldown/c in cooldowns)
if(c.name == name)
return 1
update(mob/m)
owner = m
owner << "OK3"
for(var/Cooldown/c in cooldowns)
c.start = world.time
c.end = c.start + c.delay

Problem description:
Basicaly the proc print the "OK" but not the "OK2" and the code after it and the "OK3" in the update proc.
If I try to load it just shows the "Loading..." and nothing changes. But if I delete the savefile after trying loading and start a new one, I can see the old character in the place that I saved.

I feel like I already had this problem before but I don't if I post here for help.
Try not to copy paste other people's codes. This is, obviously, ripped off.

First of all, there is alot more ways to do Save/Load processes, try looking up the Write() and Read() processes.
This is not a rip off!
Why do you think it is?
In response to Gland Mopa
Best response
Gland Mopa wrote:
This is not a rip off!
Why do you think it is?

You're saving each variable seperatedly, which is normally used in "older" sources, were people only coded DBZ etc. Either way, it doesn't matter if it's a rip or not, simply look up the Write() and Read() processes, it'll shorten your code by a whole lot, and help you identify the problem.
mob
player
var
lastx
lasty
lastz
Write(savefile/F)
lastx = x
lasty = y
lastz = z
..()

Read(savefile/F)
..()
unfreeze()

for(var/obj/getAble/equipAble/o in contents)
if(o.equipped)
_unequip(o)
_equip(o)

refreshMacros()
coolM.update(src)

loc = locate(lastx, lasty, lastz)

proc
Save()
src << "Saving..."
if(fexists("Saves/Players/[src.ckey].sav"))
fdel("Saves/Players/[src.ckey].sav")
var/savefile/F = new("Saves/Players/[src.ckey].sav")
Write(F)
src << "Game Saved."
return 1

Load()
src << "Loading..."
if(fexists("Saves/Players/[src.ckey].sav"))
var/savefile/F = new("Saves/Players/[src.ckey].sav")
Read(F)

src << "Game Loaded."
return 1

else
src << "You do not have a character."
return 0


Now everything is working. Thank you!