I need a hand with saving characters...well, sort of.
Yes, I have looked through Deadron's lib, but it is based around saving all of the character's stats.
I need to save a few stats of my choice, to be loaded up when the character re-enters.
I'm a bit foggy on BYOND's saving system, so I have come here in search of enlightenment. ;)
Thankyap.
ID:149367
May 14 2002, 6:24 am
|
|
Malver wrote:
I need a hand with saving characters...well, sort of. Basically the idea is to create a save file, change to the right directory within the save file (see savefile.dir and savefile.cd), and then save vars there: mob That's about all there is to it, really. Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Malver wrote: mob That's about all there is to it, really. What about loading? |
In response to Malver
|
|
Malver wrote:
What about loading? Under the system I wrote, loading could work exactly the same way--but by reversing the << operator so that it becomes >> instead. Lummox JR |
In response to RaeKwon
|
|
RaeKwon wrote:
Im at school so made this in notepad, hope it helps. or this login, more styles of saving mob/Write(savefile/F) - RaeKwon What about making it so if the player didn't exsist it would run createcharacter proc? EDIT: N/M I missed that last part of his post my bad. EDIT of the EDIT: Ok so n/m again that code that I saw is the one I was trying. All I need is a snippet that will call a proc if the player does not exsist. I can do the saved variable my self thx. |
In response to Lummox JR
|
|
Lummox JR wrote:
Malver wrote: It works fine. I need to do the same with objects. <code> obj var/list/savestats=list("thing1","thing2","thing3") </code> With the same save/load proc as before, but as <code>obj</code> instead of <code>mob</code>. This prevents me from calling the proc when the player logs in. <code> Declarations.dm:144:error:LoadThing:undefined proc Declarations.dm:147:error:SaveThing:undefined proc </code> Of course they are defined, but they are not under mob. There is a way to do this, but due to my overall newbie-ish-ness, I can not seem to come up with it. Any help? :) |
Malver wrote:
I need to save a few stats of my choice, to be loaded up when the character re-enters. Just define any stat that isn't to be saved as a tmp variable...then use my library or some copy of it. Or read http://www.deadron.com/Games/ByondBasicSavefiles.html and roll your own from scratch. |
mob/Logout()
var/savefile/F = new(ckey)
Write(F) // Writes the savefile.
del(src)
mob/Login()
var/savefile/F = new(ckey)
Read(F) // Reads the save file
return ..()
mob
var
saved_x
saved_y
saved_x
Write(savefile/F)
saved_x = x
saved_y = y
saved_z = z
..() // store variables
Read(savefile/F)
..()//restore variables.
Move(locate(saved_x,saved_y,saved_z))
or this login,
mob/Login()
SaveFile.cd = "/"
if(ckey in SaveFile.dir)
SaveFile.cd = ckey
Read(SaveFile)
usr << "Welcome back."
else
usr << "Welcome."
more styles of saving
mob/Write(savefile/F)
F << x
F << y
F << z
..()
mob/Read(savefile/F)
var {saved_x;saved_y;saved_z}
F >> saved_x
F >> saved_y
F >> saved_z
..()
Move(locate(saved_x,saved_y,saved_z))
//Storeing Variables//
mob/Write(savefile/F)
F["name"] << name
F["icon"] << icon
mob/Read(savefile/F)
F["name"] >> name
F["icon"] >> icon
- RaeKwon