ID:174242
 
Yes, that's right! I HAVE got myself into ANOTHER pickle!

Here is my problem, nice and simple.
When I login, make a new character and save, it saves. :P
But when I click continue, which is meant to load my character I get a black screen!

Here is my code:

world/mob = /mob/Player  //This makes the default mob to login to a PC.


mob/Player/Login() //Let's get started:
var/I = input("What would you like to do? (You are only allowed one Character per Key, creating a new one will delete the old...)","Logging in:","Continue") in list("Continue","Create New Character") if(I == "Continue") //If the player selected continue...
var/savefile/F = new(client.Import())
if(F)
F["X"] >> X
F["Y"] >> Y
F["Z"] >> Z
Read(F)
src.loc = locate( X, Y, Z )
else
usr << "You don't have a character saved!"
return()
I = "Create New Character" //Turn I back to "Create New Character" so when it gets to that part of the proc below, it will make the person create a new one.
if(I == "Create New Character") //If they selected to create a new character or if it couldn't find a savefile which is defined above...
Name_Character() //Call this proc which is defined below the Login() proc. This is the same as calling src.Name_Character().
usr<<"[usr], you are complete!"
usr<<"May you prosper in your adventures"
usr<<" "
sleep(8)
usr<<"Live well!"
usr<<"Kill well!"
usr<<"Die well!!"
loc = locate(2,2,1)
..()

mob/proc/Name_Character() //This is a proc we called above in Login().
var/N = input("What would you like your name to be?","Name:",key) as text //The input() proc can also be used to get text form the player, or number, type, or whatever!
if(N == ""||N == null) //If the player did not put anything...
alert("You need to enter a name!") //Tell him this...
spawn() //This is used to make loops that could or do go on forever not crash. You can also put a delay in 1/10s of a second in the arguments to make it wait before calling the proc that is called after it.
Name_Character() //And make him do it again!
else //If the player did enter something...
if(length(N) < 25) //Here is that old length() proc again. This time it checks to make sure the player's name he defined isn't too long.
name = N //Make that mob's name into what the player wanted it to be.
else
//If it is too long...
alert("Your name was too long, it must be below 25 characters!") //Do this stuff again:
spawn()
Name_Character()

var
X
Y
Z

mob/proc/Save_Character() //Ok, now back to the saving stuff. The type of savefiles we are using are unique because they are client-side savefiles, meaning you can login to someone elses server and still have your character.
var/savefile/F = new() //This makes a new savefile. The variable F now means the savefile...
Write(F) //The Write proc, like the Read proc will do savefile saving for you. This however, unlike Read(), will save the players mob that he/she has into the savefile specified.
client.Export(F) //This will put that savefile into your \BYOND\users\[Your name here]\Keyinfo\ folder.
src << "[src.name] saved." //Tell the src that it has been saved.
F["X"] << src.x
F["Y"] << src.y
F["Z"] << src.z

mob/Player/verb/Save() //We gotta let the player do it manually, right?
set category = "Commands"
src.Save_Character() //Save the character with the proc we defined above.


This is for my game : Dolores Vindicta, a new RPG waiting to take BYOND by storm!

(It roughly translates "The Greif of Revenge" and it sounds kinda cool too!)

~GokuSS4Neo~