ID:171943
 
im having a little trouble understanding deadrons character handling as in how it works. see what i want to do is make my own create new character/load character interface (one that doesnt involve pop up alerts) but deadrons coding confuses me to no end. i was wondering if someone could give me the key points to understanding save file stuff so i can make my own system or if someone could help me make sense of how to customize deadron's system. any help at all would be very very much appreciated.
yea, deadron is a pro. coder!

i suggest u download easier sources.
just search for "Login" or "saving" or something.. in libary/demos.

Deadron is hard to understand for n00bs..

In response to ShakerDeath
eh well i dont really want to trust anyone elses system with my save files... i guess ill just have to slowly decypher it.
In response to ShakerDeath
ShakerDeath wrote:
Deadron is hard to understand for n00bs..

Well, Deadron's libraries are just meant to be "plugged in" not understood (unless you want to).
//siefer's savefile help

mob
text="<font color=red>@"
proc
Save()
var/savefile/F=new("insert directory name of your choice here/[src.ckey].sav")
//two possible ways to save the mob..
//F["mob"] << src //first way, store the entire mob inside of the savefile
//i'm not too familiar with this method, but i know a few people use it
//this can also be used to store specific variables like:
//F["weapon"] << src.weapon

src.Write(F) //second, easier way. Look up Write in the reference for an explanation
//this saves all of the mob's non tmp/global/const vars to the savefile F
//to save a location...
F["lastx"] << src.x //make a spot in the savefile called lastx, and put src's surrent s position in it
F["lasty"] << src.y //same with y..
F["lastz"] << src.z //..and same with z

Load()
var/savefile/F=new("insert directory name of your choice here/[src.ckey].sav")
//src << F["mob"] //use this to retrieve data stored the first way, i.e.:
//src.weapon << F["weapon"]

src.Read(F) //use this method to read the data into src stored in F via Write(F)

//to load a location..
var/newX //variables to hold the contents of the savefile's lastx, lasty, and lastz
var/newY
var/newZ
F["lastx"] >> newX //load each variable from the savefile
F["lasty"] >> newY
F["lastz"] >> newZ
src.loc=locate(newX,newY,newZ) //and put src on that spot


Login()
..()
src.sight=1 //so they can't see anything before they choose
var/list/asklist=list("Create") //list of options to choose from
if(fexists("insert directory name of your choice here/[src.ckey].sav")) //if there is already a savefile..
asklist+="Load" //give the option to load it
var/ask=input("What do you want to do?","[world.name]") in asklist
switch(ask)
if("Create")
src.sight=0 //let them see again
src<<"Welcome!"
if("Load")
src.Load() //if they had the option to choose load, and they DID choose it, load their character
src.sight=0 //let them see
src<<"Welcome Back!"

Logout()
src.Save() //this takes care of the need for saving in-game, because there's no way around mob.Logout()
..()


//demo stuff
world
maxx=10
maxy=10
maxz=1
turf=/turf/green

turf
green
text="<font bgcolor=green color=#006600>."


It started out just being a snippet, but i got carried away, this is more like a total demo...

Anyway, I hope this helps you.

<small>note: To anyone reading this, if there's a bug, or i stated something the wrong way, please excuse me, i whipped this up in about 3 minutes.</small>

~FM
ok, the most easyest save:
client/New()
var/savefile/F = new(ckey)
F >> usr
..()
client/Del()
var/savefile/F = new(ckey)
F << usr
del(usr)

This save saves EVERYTHING(including mobs inside the mob), besides the location- because location can't be saved
The save file will be sent to the host

if you want to save the file to the client
client/New()
var/savefile/F = usr.Import()
F >> usr
..()
client/Del()
var/savefile/F = usr.Export()
F << usr
..()

if you save to the client you can use the file in different world useing the same file format

the difference between << and write is that >> saves everything (besides location) and write saves only VARS

same way the other way: >> loads everything and read loads only vars

if you don't want a var to be saved you give it the tmp flag
mob
var/tmp
hi = "hi"
mob/dude = /mob/dude

these are helpfull for things like random combat, makes sure when you login, you don't start in a battle
In response to Theosco
Actually, location is really easy to save:

proc/Save()
var/savefile/F = new("players/[src.ckey].sav")
F["X"] << src.x
F["Y"] << src.y
F["Z"] << src.z


Edit: btw, search characterhandling and go to griswald's characterhandling. It's a simple and useful demo.
In response to Rippy
don't forget to add the load location to that Rippy
In response to Theosco
I know, I was just giving a quick example.