ID:2229869
 
(See the best response by Kaiochao.)
So I noticed that when I add a datum to a savefile, a Save.lk file appears also I noticed that when I try world<<s.ExportText(); it won't display anything until I restart the game.

Now when I save simple primitive value (nums, characters etc.) I can see the contents with ExportText instantly

Is this the case that it takes longer to save a datum??
Or Idk maybe it works as a refference and it keeps being updated or something??
That would be pretty unsafe if thats the case.
Best response
The .lk file is a lock that prevents the savefile from being written to multiple times simultaneously, which would probably corrupt the file.

Are you getting any run-time errors during the saving process? If it's crashing during saving, then it'll never finish saving, so the savefile may never be unlocked.

It's also possible that it's simply taking a very long time, but you would normally run out of memory before it took a really long time.
Yeah you are right it crashes it can't save players client maybe because I am a guest.
The crash was buried in all my debugging info.

Also I noticed that when I save a datum also the datums contained in this datum are saved as well. So what exactly happens there?? I am afraid of memory leaks and duplicate datum

eg.
Country
var/Town/town1
var/Town/town2
Town
var/Name
var/Country/country //there I have a bidirectional reference which is frequently used in my game
mob/verb/Load()
var/savefile/s=new("Savefiles/save1.sav")
var/Country/country;
var/Town/town1;
s["country"]>>country
s["town1"]>>town1


So here I'm worried about loading. Will I get duplicate datum or byond handles that?? (didn't include directories and safety checks for simplicity)
In response to Victorqr
BYOND savefiles handle circular references by saving/loading the entire cycle when a single object in the cycle is saved/loaded.

If town1 is saved/loaded by country, then saving/loading it separately will result in a duplicate.
Thanks so if I mark these reference vars as tmp and assign them manually will that work?? I mean thats why tmp is there??
Basically /tmp means the var will never be saved. It's a good idea for anything that would have no meaning in a savefile, OR that runs the risk of saving extra data you don't want.
Thx for the explanations its my first time using savefiles but everything seems to work well now :) ohh just one more thing in a tutorial in byond I read that you have to use text2num() to convert the value you got from a savefile but while testing it I noticed that it returns numerical values correctly and not as text
Yes, you can save numbers directly in a savefile. You only need text2num() if you're loading from a text file or something similar.