ID:1840121
 
(See the best response by Lummox JR.)
So I've given saving areas to a file a go and I've come into multiple issues and so I'm reaching out to anyone who can just fast track me on how to do this or let me know it's not possible or is flawed. It's possible I just don't know what I'm doing and that's why I keep failing.

From what I can tell when you save an area it saves a list of everything in the area which is not actually what I want. All I want is the turf in the area. For example:



You'll notice in this save file 175 is my mob. In fact it's my mob with zero locational data. Yeah, everything that isn't a turf doesn't get locational data, why? Because, that's why.

When I defined the area all I cared about was what turf my area encompassed anyway. What I would love to do is this:

area
store
Enter()
src << "Hey, welcome to the store"

proc
saveStore()
var/area/store/storeArea = locate(/area/store)
storeArea.Write(new/savefile("storeArea.sav"))
del storeArea

loadStore()
var/area/store/storeArea
storeArea.Read(new/savefile("storeArea.sav"))


With that I could save areas I want and bring them back onto the map when I want. So what actually happens when you run this code? Weird ****, that's what happens. If you were in the store at the time you'll be teleported around when it loads and you won't even be teleported back to where you were. If you're not logged in it'll still load your mob in the store but just in some weird location.

Is it just me or is loading and saving areas either broken or really hard to do? How do I do it? Thanks to anyone who can help, you deserve a sticker :)
Best response
You definitely don't want to save areas directly. That saves the turfs, and everything on them--including mobs--which can cause major problems for you later on.

The code example you posted, though, won't work at all. Problems:

1) You want Entered(), not Enter(), for this.

2) In Entered(), you want to send output to the mob that entered--which should be an argument to the proc, not src (and definitely not usr).

3) Why are you deleting the area after saving it?

4) You can't call Read() on a null value.

Now as for dealing with the way that areas save, so you can get around the fact that they save their entire contents, I would suggest overriding Write() and Read() so you can save a list with turf location data. Ideally, you could break that down into blocks, so you'd only need to save and load minimal info.