ID:147452
 
I have done something wrong, but I don't know what! Every time I make a new character, it is fine, but when I log into that character the next time it doesn't load his vars. Also, I can only run the game from DreamMaker, I can't use the Bookmark thing on DreamSeeker. Here is my code:

    Write(savefile/F)
..()
if(istype(usr,/mob/Boats))
var/mob/Boats/A = src
F.name = A.name2
F["last_x"] << x
F["last_y"] << y
F["last_z"] << z
for(var/mob/Boats/B in src.Ships)
F["[B]_x"] << B.x
F["[B]_y"] << B.y
F["[B]_z"] << B.z
world<<"[B.x],[B.y],[B.z] = [B].loc!"
Read(savefile/F)
..()
var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)
for(var/mob/Boats/B in src.Ships)
var/B_x
var/B_y
var/B_z
F["[B]_x"] >> B_x
F["[B]_y"] >> B_y
F["[B]_z"] >> B_z
B.loc = locate(B_x,B_y,B_z)
PortCheck(B)


Thank you for your time!

~Ease~
I'll be all the help I can with this.What variables are you talking about...health and stuff or location variables? If you are saying that your health wont load then it's because you didn't save those variables. And I think your game wont run on Dream Seeker because it might not be published. In Dream Maker I think the game runs from the open code. Sorry if I said anything wrong and please don't flame me
In response to Dark Sin
Don't worry, I won't flame you, you were only trying to help, but unfortunately you were slightly wrong. I know very little/none about saving and loading, but I am pretty certain that the "..()" in the Write bit tells it to save all of the vars except location. The reason I think this is that a couple of days ago the Reading and Writing worked fine, it's only now that I've changed something (I can't remember what!) that it doesn't work!

Also, you don't need it published to run of DreamSeeker, as before yesterday, every time I tried to run it from DreamSeeker it worked fine, it is only now that I have changed something that it won't!

Thanks for the attempted help though. Don't worry, if you are trying to be helpful people won't flame you (except Lummox if you used "usr" in a proc, or Garthor...because he flames everyone :P)

~Ease~
In response to Ease
Well... if it used to work and now doesn't, I'd suspect one of two things:

1. You overrided the Read()/Write() procs elsewhere.

2. You changed how you're saving/loading (I mean with the << and >> savefile operators, that cause the Write()/Read() procs to be called). If #1 doesn't work, perhaps you could post those snippets as well.

If both of those fail, it would be handy to know whether the problem is in the saving or loading. There's an example of a savefile viewer in the reference under ExportText().
In response to Crispy
Well that's odd...I ran the example in ExportText, and it gave me a really messed up load of text. Then I made a new character, deleting the old one, and tried again, and it worked fine! Now, no matter how hard I try it works fine every time!

Thanks Crispy :S

[EDIT]Somehow, quite oddly, a backup version had replaced the newest version, hence why it worked. However, it now has a problem. Whilst in a ship, your name is the Ships name, but if you save you end up with two saved files. One as the ship, and one as yourself. So I changed the code to fix that, and it didn't work:

    Write(savefile/F)
..()
F["last_x"] << x
F["last_y"] << y
F["last_z"] << z
if(istype(src,/mob/Boats))//If it is a ship, name the file after the owner.
var/mob/Boats/A = src
F.name = A.name2
//Get the Player - who is inside the ship.
var/mob/MAN/B
var/list/L = new/list()
for(B in A.contents)
if(B == A.Owner)
L.Add(B)
B = L[1]
for(var/mob/Boats/C in B.Ships)
F["[C]_x"] << C.x
F["[C]_y"] << C.y
F["[C]_z"] << C.z
else
for(var/mob/Boats/A in src.Ships)
F["[A]_x"] << A.x
F["[A]_y"] << A.y
F["[A]_z"] << A.z


Now it doesn't save the ships at all, whether you are a ship or not!
[/EDIT]

~Ease~