ID:140266
 
Code:
mob/proc/Save()
var/savefile/F=new("savefiles/[usr].sav")
F["HP"] << hp
F["name"] << name
F["gender"] << gender
F["str"] << str
F["dex"] << dex
F["int"] << int
F["con"] << con
F["soul"] << soul
F["luck"] << luck
F["char"] << char
F["det"] << det
usr << "<font size = 20 color= red>Game Saved.</font>"


mob/proc/Load()
if(fexists("savefiles/[usr].sav"))
var/savefile/F=new("savefiles/[usr].sav")
Read(F)
F["HP"] >> hp
F["name"] >> name
F["gender"] >> gender
F["str"] >> str
F["dex"] >> dex
F["int"] >> int
F["con"] >> con
F["soul"] >> soul
F["luck"] >> luck
F["char"] >> char
F["det"] >> det

mob/verb/save()
Save()


Problem description:
I know this may look not well done but it works.(For HP,name and gender)It's not working for str to det.
Anyone know why?

Thanks in advance.

Blafblabla wrote:
Code:
> mob/proc/Save()
> var/savefile/F=new("savefiles/[usr].sav")
> F["HP"] << hp
> F["name"] << name
> F["gender"] << gender
> F["str"] << str
> F["dex"] << dex
> F["int"] << int
> F["con"] << con
> F["soul"] << soul
> F["luck"] << luck
> F["char"] << char
> F["det"] << det
> usr << "<font size = 20 color= red>Game Saved.</font>"
>
>
> mob/proc/Load()
> if(fexists("savefiles/[usr].sav"))
> var/savefile/F=new("savefiles/[usr].sav")
> Read(F)
> F["HP"] >> hp
> F["name"] >> name
> F["gender"] >> gender
> F["str"] >> str
> F["dex"] >> dex
> F["int"] >> int
> F["con"] >> con
> F["soul"] >> soul
> F["luck"] >> luck
> F["char"] >> char
> F["det"] >> det
>
> mob/verb/save()
> Save()
>

Problem description:
I know this may look not well done but it works.(For HP,name and gender)It's not working for str to det.
Anyone know why?

Thanks in advance.


You don't need to save every individual variable. Just the mob itself which contains the variables. The mob is loaded with all of it's information.

Post [link]
In response to Hulio-G
Thanks, that's a undefined var error if you do that.
In response to Blafblabla
Blafblabla wrote:
Thanks, that's a undefined var error if you do that.

This post does not make any sense. If you are actually getting an error with my code (which, in this case, you won't unless you've utterly messed it up) then post the exact error and where it occurs.
In response to Garthor
I dont know why the code isnt working, check if you arent redefining the vars in the Login proc

@Garthor
His way is better then yours cuz if he ever decide to change one of the variables he can just remove his entry in the save file and it wont bug up the savefile(i.e wont need to wipe the savefile).

So since he is trying to make his savefiles that way, you might as well help him do it that way
In response to Abrax
Abrax wrote:
I dont know why the code isnt working, check if you arent redefining the vars in the Login proc

@Garthor
His way is better then yours cuz if he ever decide to change one of the variables he can just remove his entry in the save file and it wont bug up the savefile(i.e wont need to wipe the savefile).

So since he is trying to make his savefiles that way, you might as well help him do it that way

What are you babbling on about, here? Could you give an actual example as to how his way is better? Because changing variables is not going to "bug up" a savefile.
In response to Garthor
If you remove an entry from a savefile it will crash the save file thus making you have to delete it.

Lets say you make a Quest variable, then you decide you want to take the quests out, in your way, the quest variable could never be deleted( erased at compile time ) or the savefile would crash
In response to Abrax
Or you could leave the variable in without using it?

His way is in no way better. It completely removes the use of /tmp/ variables and whatnot. Have fun reading/writing 100+ variables dawg.
In response to Abrax
Abrax wrote:
If you remove an entry from a savefile it will crash the save file thus making you have to delete it.

Lets say you make a Quest variable, then you decide you want to take the quests out, in your way, the quest variable could never be deleted( erased at compile time ) or the savefile would crash

One minute of experimentation shows that this is not the case. Now, would you kindly stop spreading misinformation?