ID:175176
 
ok, see the problem is it doesnt save where the player is located, instead you go back to the beginning city. Can someone help me?

mob/proc/Save_Character() //Ok, now back to the saving stuff. The type of savefiles we are using are unique because they are client-side savefiles, meaning you can login to someone elses server and still have your character.
var/savefile/F = new() //This makes a new savefile. The variable F now means the savefile...
Write(F) //The Write proc, like the Read proc will do savefile saving for you. This however, unlike Read(), will save the players mob that he/she has into the savefile specified.
client.Export(F) //This will put that savefile into your \BYOND\users\[Your name here]\Keyinfo\ folder.
src << "[src.name] saved." //Tell the src that it has been saved.

mob/PC/verb/Save() //We gotta let the player do it manually, right?
set category = "Communication"
src.Save_Character() //Save the character with the proc we defined above.
Two quick tips when posting code:

1) You'd probably be better off writing al the comments above the actual code, or somewhere that doesn't get them meshed together with the code (unless one line of code is really confusing). Keeping the code clean up comments makes it more readable, so I suggest keeping the comments out of the way, since the browser doesn't color-code your code for you like DreamMaker does.

2) Always surround them in:
<code></code>
tags.
In response to Foomer
ok thanks, ummmm here:

<code>mob/proc/Save_Character() var/savefile/F = new() //This makes a new savefile. Write(F) //The Write proc, like the Read proc will do savefile saving for you. client.Export(F) src << "[src.name] saved." //Tell the src that it has been saved. mob/PC/verb/Save() //We gotta let the player do it manually, right? set category = "Communication" src.Save_Character() //Save the character with the proc we defined above.</code>
In response to Nave
This is what I mean. I can understand this.

<code>mob/proc/Save_Character() var/savefile/F = new() Write(F) client.Export(F) src << "[src.name] saved." mob/PC/verb/Save() set category = "Communication" src.Save_Character()</code>

If you haven't already, maybe you should review the Guide under Savefiles.
In response to Foomer
Foomer wrote:
This is what I mean. I can understand this.

<code>mob/proc/Save_Character() > var/savefile/F = new() > Write(F) > client.Export(F) > src << "[src.name] saved." > > mob/PC/verb/Save() > set category = "Communication" > src.Save_Character()</code>

If you haven't already, maybe you should review the Guide under Savefiles.


I have read it and it didnt help me, or someting, plz help me.
In response to Nave
To be quite frank, any information I'd give you on the topic would be straight from the Guide anyway. If you can't get your savefiles to save location, and the guide didn't help you, then you need to look over the guide again, because it shows you how to do that.
In response to Foomer
i think this is it? but i dont under stand it


2.1 tmp Variables
A few things are not saved. For example, the mob's location is not restored. That is because the location is a reference to an external object (like a turf). If that value were written to the savefile, it would be treated just like an item in the contents list--the whole object would be written to the savefile. That is certainly not what you want in the case of the mob's location.

Variables like loc are called temporary or transient variables, because their value is computed at run-time (when the mob is added to the contents list of a turf). In some cases, temporary variables would just be wasting space in the savefile, but in others (like loc), it would be incorrect to save and restore them as though they were objects "belonging" to the player.

The Write proc already knows about the built-in temporary variables. If you define any of your own, however, you need to mark them as such. You do that with the tmp variable type modifier. The syntax is just like global and const.

The following example defines some temporary variables that reference external objects. We don't happen to want those objects (in this case other mobs) to be saved along with the player. Since there is no way for the compiler to know that, we have to tell it by using the tmp flag.


mob
var/tmp
mob/leader
followers[]

In response to Foomer
Wow. Theres "code" and "/code" tags too? I thought there was just DM /DM tags.
In response to Airjoe
The DM tags encode HTML as well, but the code tags just format the text.
In response to Foomer
well can you help me??
In response to Nave
No. Read the material over until you understand it. :P I can't write anything here that will help you any more than the provided material can.
In response to Foomer
i put loc at the bottom?
In response to Nave
Read the section just after the section you posted. It explains location saving in detail.
In response to Flick
mob/proc/Save_Character()
var
savefile/F = new()
saved_x
saved_y
saved_z
Write(F)
saved_x = x
saved_y = y
saved_z = z
client.Export(F)
src << "[src.name] saved."
mob/PC/verb/Save()
set category = "Communication"
src.Save_Character()


i get a The Adventures of Perspolis.dm:442:error: proc definition not allowed inside another proc
In response to Nave
What line of code is the error on?
In response to Airjoe
The Write(F) line, of course.
In response to Garthor
mob/proc/Save_Character()
var
savefile/F = new()
saved_x
saved_y
saved_z
Write(F)
saved_x = x ***
saved_y = y
saved_z = z
client.Export(F)
src << "[src.name] saved."
mob/PC/verb/Save()
set category = "Communication"
src.Save_Character()



*** = error

i get a The Adventures of Perspolis.dm:442:error: proc definition not allowed inside another proc
In response to Nave
What happens, if instead of making a proc and a verb, just make a verb with the proc stuff in it. Probobly get the same error. Just a suggestion.
In response to Nave
Everything between Write() and Export() is indented too much.
In response to Garthor
it not working now im confused
Page: 1 2