mob/proc
ASave()
var/savefile/A = new("saves/[src.key]_A.sav") //creates a new savefile or overwrites an old one
A["X"]<<src.X //this saves a variable to the savefile, the << point at where youre sending the data
A["Y"]<<src.Y
A["Z"]<<src.Z
A["dir"]<<src.dir
A["icon_state"]<<src.icon_state
A["contents"]<<src.contents
A["Stamina"]<<src.stamina
A["MaxStamina"]<<src.maxstamina
A["Wounds"]<<src.wounds
A["MaxWounds"]<<src.maxwounds
A["Chakra"]<<src.chakra
A["MaxChara"]<<src.maxchakra
A["Current_Exp"]<<src.Exp
A["NextExp"]<<src.Nexp
A["Account_Made"]<<ACCmade
LoadA()
if(fexists("saves/[src.key]_A.sav"))
var/savefile/A = new("saves/[src.key]_A.sav")
var/X
var/Y
var/Z
A["yourX"]>>X
A["yourY"]>>Y
A["yourZ"]>>Z
A["dir"]>>src.dir
A["icon_state"]>>src.icon_state
A["contents"]>>src.contents
A["Stamina"]>>src.stamina
A["MaxStamina"]>>src.maxstamina
A["Wounds"]>>src.wounds
A["MaxWounds"]>>src.maxwounds
A["Chakra"]>>src.chakra
A["MaxChara"]>>src.maxchakra
A["Current_Exp"]>>src.Exp
A["NextExp"]>>src.Nexp
A["Account_Made"]>>ACCmade
src.loc=locate(X,Y,Z)
return 1
else return 0
client
Del()
if(src.mob)
if(Aactive == 1)
src.mob.ASave()
mob/verb
Delchar()
set hidden = 1
switch(input("Select a Character to delete.", text) in list ("Character 1","Character 2","Character 3","Nevermind"))
if("Character 1")
switch(input("Are you sure you want to delete character 1?", text) in list ("No","Yes"))
if("No")
return
if("Yes")
var/savefile/A
del(A)
Loadchar()
set hidden = 1
winshow(src, "newload", 0)
winshow(src, "loading", 1)
switch(input("Select a Character to load.", text) in list ("Character 1","Character 2","Character 3","Nevermind"))
if("Character 1")
src.stunned = 0
winshow(src, "loading", 0)
winshow(src, "default", 1)
LoadA()
src.stunned = 0
// var/savefile/A = Read("saves/[src.key]_A.sav")
Cactive = 0
Bactive = 0
Aactive = 1
new/obj/card1(src.client)
new/obj/card2(src.client)
new/obj/card3(src.client)
new/obj/card4(src.client)
new/obj/card5(src.client)
new/obj/card6(src.client)
new/obj/card7(src.client)
new/obj/card8(src.client)
new/obj/card9(src.client)
new/obj/card0(src.client)
/var/Cactive = 0
/var/Bactive = 0
/var/Aactive = 0
/var/ACCmade = 0
mob
verb
clicktitlescreen()
set hidden = 1
winshow(src, "Entrance2", 0)
winshow(src, "newload", 1)
verb
Newchar()
set hidden = 1
winshow(src, "newload", 0)
winshow(src, "default", 1)
switch(input("Select a slot to create your character in.", text) in list ("Character 1","Character 2","Character 3","Nevermind"))
if("Character 1")
if(ACCmade == 1)
return
alert("You already have a character in slot 1!")
else
ACCmade = 1
Cactive = 0
Bactive = 0
Aactive = 1
src.stunned = 0
src.loc = locate(8,35,1)
src.icon = 'mob.dmi'
src.icon_state = "walk"
src.density=1
new/obj/card1(src.client)
new/obj/card2(src.client)
new/obj/card3(src.client)
new/obj/card4(src.client)
new/obj/card5(src.client)
new/obj/card6(src.client)
new/obj/card7(src.client)
new/obj/card8(src.client)
new/obj/card9(src.client)
new/obj/card0(src.client)
1
2
ID:157490
Feb 27 2010, 1:21 pm (Edited on Feb 27 2010, 5:15 pm)
|
|
How would I go about fixing this save system. It doesnt work at all =(. This is only 1 out of 3 of these things some of them are basically copied and changed from A to either B or C. But this doesn't work.
|
Feb 27 2010, 2:44 pm
|
|
[link]
|
I'm gonna assume you get some errors from this. And by some I mean a lot, cause I can see 2 just from browsing the first 2 functions.
So yeah, post errors please. |
In response to Keeth
|
|
Garthor, can you show me an example of what you mean here: No. You would call Save() with a different argument to save in a different directory in the savefile. Save(1) saves in directory "1", Save(294) saves in directory "294", and Save("Bacon") saves in directory "Bacon". There is no particular reason to actually have three separate files instead of just three directories in the same savefile. Like, actually make that part save in a different file if a different key was active. |
In response to Darkjohn66
|
|
Maybe you should respond to Garthor's post so he knows you responded to him, instead of responding to mine.
I'd also suggest doing what Garthor suggested, because what you have there doesn't look very good at all. |
In response to Darkjohn66
|
|
Garthor wrote:
client With this code that Garthor provided, you can call client.Save("Slot1") and it will save the Slot 1 into a directory in the save file instead of having multiple files for slots X Y and Z. This would mean each player would have 1 save file that was named after their ckey.sav. What you are doing with the code snip it that you originally posted is saving only the verbs you specify rather than using the built in write proc to save every non-default/non-temp variable. --- In your code above there are many errors such as calling returns before the code completes, not checking to see if you can actually load the character before trying to load and set it to logged in. You will need to be more specific at what is going wrong and where to help you narrow down your problems. |
In response to Garthor
|
|
Im sorry I am confused. Can you show me exactly where in that code I would put client.Save("slot1")
|
In response to Darkjohn66
|
|
Nowhere.
Oh wait, SHOW you? Okay: client |
In response to Garthor
|
|
How would I go about using an If statement to decide whether slot 1 or slot 2 was loaded and write to the proper slot? Thanks for the help by the way! I will keep trying to figure this out as best I can.
--<small>I realized my foolish mistakes I had made.</small> Edit- Ok Garthor, didn't realize it would be that simple. Should I make it a tmp variable? I am going to attempt to make something where I could get the first letter of a person's key and have it save in the corresponding folder. |
In response to Darkjohn66
|
|
By using a variable to keep track of it? I mean, it's right there when you load, so just stick that in a variable and use that variable when you need to save.
|
In response to Garthor
|
|
Am I going about this the proper way?
mob/proc/load() |
In response to Darkjohn66
|
|
No. First of all, you should not be calling Read() directly. You should be using the >> operator or, instead, just calling the client/Load() proc which is defined right there for you. Next, you aren't actually opening the savefile (but if you call Load() it'll do that for you). Also, you aren't actually putting anything into the "slot" variable. Oh, and if("1") is always going to be true. You might have meant to put a switch statement there, but that's silly anyway because you might as well just store the result of the input in a variable and call Load() with that.
Oh, and I just noticed: fexists() isn't going to tell you if a directory in a savefile (which you haven't even opened yet) exists. You'd need to search F.dir for that. |
In response to Garthor
|
|
Why is a slot variable being defined inside of the Load parentheses. Wouldn't this just cause me to only be able to search for the variable slot?
|
In response to Darkjohn66
|
|
Er...Hopefully this is good?
var/slot edit-Ok I'll test it first, I probably should have *hits self in head*. |
In response to Darkjohn66
|
|
I'm not going to help you if you don't even bother to take ten seconds to test the code yourself.
|
In response to Garthor
|
|
I am getting a null error. Man, this save system stuff is tough. Well, here's what I've got. Any help is appreciated.
mob/verb/Newchar() <small> <font color=green> runtime error: Cannot execute null.Save(). proc name: Logout (/mob/Logout) usr: Darkjohn66 (/mob) src: Darkjohn66 (/mob) call stack: Darkjohn66 (/mob): Logout() Darkjohn66 (/client): Load(1) Darkjohn66 (/mob): Newchar() runtime error: bad client proc name: Newchar (/mob/verb/Newchar) usr: Darkjohn66 (/mob) src: Darkjohn66 (/mob) call stack: Darkjohn66 (/mob): Newchar()</small></font color=green> Newchar is the verb I am executing when I click on button in skin. |
In response to Darkjohn66
|
|
client is null when Logout() is called, because Logout() is called in response to client being changed. Move the call to the save procedure to client/Del().
Also, there's no reason to have that duplicated code in the switch() statement. All you should have there is "slow = input() in list()" and then an "are you sure?" message. |
In response to Garthor
|
|
This is really getting agrivating the amount of time I am spending on this /=. I changed this to client/Del() and once again got another error, I tried changing everyhing to use mob in the save and load procs but nothing seems to work. This is so hard!
|
In response to Darkjohn66
|
|
Fixing a fundamentally broken system is always more difficult than just doing it right the first time.
|
In response to Garthor
|
|
Can you please show me how I would go about setting up a slot? Please? /=. I have been trying hard and spending a large amount of time on this. I mean like actually doing a slot for me so I could set up the other 3...
|
1
2