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.
First of all, there is alot more ways to do Save/Load processes, try looking up the Write() and Read() processes.