The Save and Load proc
client
proc
Save()
if(src.mob.save_file_1==1)
var/savefile/save
save = new ("Player Saves/[mob.ckey]/Save File 1.sav")
save["mob"] << src.mob
save["x"] << src.mob.x
save["y"] << src.mob.y
save["z"] << src.mob.z
if(src.mob.save_file_2==1)
var/savefile/save
save = new ("Player Saves/[mob.ckey]/Save File 2.sav")
save["mob"] << src.mob
save["x"] << src.mob.x
save["y"] << src.mob.y
save["z"] << src.mob.z
if(src.mob.save_file_3==1)
var/savefile/save
save["mob"] << src.mob
save = new ("Player Saves/[mob.ckey]/Save File 3.sav")
save["x"] << src.mob.x
save["y"] << src.mob.y
save["y"] << src.mob.z
Load()
if(src.mob.save_file_1==1)
var/savefile/load
load = new ("Player Saves/[mob.ckey]/Save File 1.sav")
load["mob"] >> src.mob
load["x"] >> src.mob.x
load["y"] >> src.mob.y
load["z"] >> src.mob.z
if(src.mob.save_file_2==1)
var/savefile/load
load = new ("Player Saves/[mob.ckey]/Save File 2.sav")
load["mob"] >> src.mob
load["x"] >> src.mob.x
load["y"] >> src.mob.y
load["z"] >> src.mob.z
if(src.mob.save_file_3==1)
var/savefile/load
load = new ("Player Saves/[mob.ckey]/Save File 3.sav")
load["mob"] >> src.mob
load["x"] >> src.mob.x
load["y"] >> src.mob.y
load["z"] >> src.mob.z
mob
proc
Auto_Save()
set background = 1
src.client.Save()
spawn(10) src.Auto_Save()
if(prob(40))
usr <<"\white Character Saved."
Creating a New Character:
turf/newchar
density = 1
layer = FLY_LAYER
Click()
if(istype(usr, /mob/Guest))
switch(alert(usr, "Which slot do you want to use?", "Slots", "Slot 1", "Slot 2", "Slot 3"))
if("Slot 1")
if(fexists("Player Saves/[usr.client.ckey]/Save File 1.sav"))
switch(alert(usr, "Are you sure that you want to overwrite your old Character?", "Character Creation", "Yes", "No"))
if("Yes")
sleep(0)
fdel("Player Saves/[usr.client.ckey]/Save File 1.sav")
Create()
if("No")
return
else
usr.save_file_1 = 1
Create()
mob/Guest
Login()
src.loc = locate(9,9,1)
proc
Create()
var/mob/newmob
var/newname = null
newname = input("What will your name be?", "Name", usr.key) as text
if(!usr)
return
if(length(newname) < 4)
alert("Your name must be at least four letters long!")
Create()
else
newname = html_encode(newname)
newmob = new /mob/PC()
newmob.icon = 'base.dmi'
if(usr.save_file_1)
newmob.save_file_1 = 1
if(usr.save_file_2)
newmob.save_file_2 = 1
if(usr.save_file_3)
newmob.save_file_3 = 1
newmob.loc = locate(44,186,1)
newmob.name = newname
usr.client.mob = newmob
del(usr)
Loading
turf/load
density = 1
layer = FLY_LAYER
Click()
if(istype(usr, /mob/Guest))
switch(alert(usr, "Which slot do you want to use?", "Slots", "Slot 1", "Slot 2", "Slot 3"))
if("Slot 1")
if(fexists("Player Saves/[usr.client.ckey]/Save File 1.sav"))
usr.save_file_1 = 1
usr.client.Load()
else
alert("No Saved File Found!")
sleep(5)
return
Note: I only use File 1 right now for testing purposes. Once I get the first savefile, I'll be able to do the rest easily.
Problem description:Okay, so the character creation works and all. Saving also seems to save into the Folder that I specified. But whenever I try to Load the game, A black screen pops up, with no character at all. Also, sometimes when I remake my character for testing I get this:
runtime error: bad savefile or list
proc name: Save (/client/proc/Save)
source file: Saving and Loading.dm, 7
usr: Test (/mob/PC)
src: Chiwy8 (/client)
call stack:
Chiwy8 (/client): Save()
Test (/mob/PC) Auto Save()
Test (/mob/PC): Login()
In case you need the Login procs that I have, here:
mob/Guest
Login()
src.loc = locate(9,9,1)
mob/PC/Login()
AdminLoad()
Auto_Save() //This I added as a way to fix the problem with the Loading Black Screen. Doesn't seem to be changing anything
..()
The Auto Save spawn time is low for testing purposes as well. I've spent hours trying to figure this out on my own, and using the notes I have for Saving and Loading. Any help will be greatly appreciated.
~Chiwy8