ID:140897
 
Code:
proc
WorldSave()
var/savefile/F = new("world.sav")
for(var/vgoldinbank)
F["vgoldinbank"] << vgoldinbank

WorldLoad()
var/savefile/F = new("world.sav")
var/atom/A
while(!F.eof)
F >> A



Problem description:

Okay, basically I am sticking the procs into the World/New() and World/Del() but no matter what I do or try, I can't seem to get them to load properly. Something is saving, because it is making the world.sav and storing some data; but nothing ever loads. Upon closing/opening server, the data disappears. I've tried world/proc, removing the var/atom/A and while bits and just using F["vgoldinbank"] >> vgoldinbank, and different other methods that I've seen discussed around the Dev Forums, but I can't really find much information about saving world vars.

A lot of the time, the entire game freezes up upon attempting to close or open it, with this in place.

If you're wondering what I'm attempting to do, if it helps any, is make a per village banking system. All villagers can use the same bank to deposit funds into so that the leader of the village can use those funds to make village defense upgrades.

Didn't want to post for help, but I'm really stumped.
while(!F.eof)


What's eof ?

Also, the WorldLoad() should only be this.

WorldLoad()
var/savefile/F = new("world.sav")
F["vgoldinbank"] >> vgoldinbank
In response to Andre-g1
eof = me being retarded and considering buffers when I don't even need to use eof.

And yeah, I changed my WorldLoad() to what you posted, but it still doesn't work properly. It gives me vgoldinbank = undefined var.

I also have it defined as a var in the vars.dm file.
In response to Acryptid
Nevermind. I overlooked something and set the var under mobs. It works now with no error, but still doesn't save/load properly. It also causes massive lag issues when opening/closing the world still.

Edit: Lol. Nevermind... Retarded errors. It works now. =/
In response to Acryptid
You should post what kind of errors you had and how you fixed them, if they're related to this, so that the 1/100 person that uses the forum search and ends up here, knows what to do ;)
In response to Andre-g1
Sure thing.
<code> world/New() ..() if(!(fexists("villagesys.sav'"))) return var/savefile/F = new("villagesys.sav") F["leafyen"] << leafyen world/Del() ..() var/savefile/F = new("villagesys.sav") F["leafyen"] >> leafyen </code>

Basically the for() I had was screwing things up, causing the lag issues when closing/opening the world, because before it had worked since I misplaced the leafyen var into mob rather than make it an actual world var.

This way you can just add in extra vars to be saved into villagesys.sav easily.


---

It all works great. If there's other stuff you want to add to the villagesys.sav other than vars (such as temporary placement of objs/mobs on the map - IE: Not having it in the coding, but rather having it where leaders can purchase the mobs to place into their village), then you just place it into the procs above.

In the end, I just made stupid mistakes that I didn't realize I had done until reviewing my coding. =/

Edited to show a better way of doing it.