ID:2087694
 
(See the best response by KuroChi.)
Hello,I tried to see a map library filler but none made me understand right.
I just want to know how I can save map turfs,objectes and areas keeping their vars on all x,y,z of map.
There are a few libraries for that. One is SwapMaps.
In response to Lummox JR
I tried to test this with a future project but it seem not worked, so I tested this library:
http://www.byond.com/developer/Dession/SwapMapsHousing
And I got more confused because it had in the game logout save world and the houses dont got saved. I tried to delete a var that places grass in the house and not worked also
I made my own map saving system, but I did follow Lummox's SwapMaps library in that I scanned through all the tiles in the world in a 3D fashion, and I saved everything in a 3D list, defined like..

var/list/turfs[world.maxz][world.maxx][world.maxy]


Reset that list only as you need it. Then, just loop through all the turfs in the world, save them in their respective location within the 3D 'turfs' list, and make a savefile out of that list.

It should look something like this..

for(var/z=1 to world.maxz)
for(var/x=1 to world.maxx)
for(var/y=1 to world.maxy)
//check if the tile should be saved
turfs[z][x][y] = locate(x,y,z)


Then the rest is pretty much saving. Keep in mind, you can check all of the objects on the tiles within these loops and save them as well. I suggest you make a separate list for that.
@Kitsueki:

block()
Wow my head is hurting. I tried all ways of making a turf saving made by players even with @Kitsueki way but it still dont save.

var/list/turfs[world.maxz][world.maxx][world.maxy]
Login()
..()
SwapMaps_Load("World map")
for(var/z=1 to world.maxz)
for(var/x=1 to world.maxx)
for(var/y=1 to world.maxy)
turfs[z][x][y] = locate(x,y,z)

Logout()
map = SwapMaps_Find("World map")
In response to Kitsueki
Kitsueki wrote:
I made my own map saving system, but I did follow Lummox's SwapMaps library in that I scanned through all the tiles in the world in a 3D fashion, and I saved everything in a 3D list, defined like..

var/list/turfs[world.maxz][world.maxx][world.maxy]


Meaning no disrespect, a multidimensional list is probably the worst approach you could have taken. The number of list objects you'll have is very high, multidimensional lists aren't terribly efficient, and you really should be using block(). (Also, z,x,y is a completely illogical order. Make it x,y,z or z,y,x.) As Ter said, you really should use block() if you want a batch of turfs in a given x,y,z range.

But aside from that, the way you propose saving turfs really won't work well at all. If you save a list of turfs directly, a number of problems are going to result. Among them:

1) Any mobs on those turfs will automatically be saved, which means players can save with the map if you're not careful.

2) Loading a batch of turfs directly won't integrate them back into the world very well, likely creating a new area on load.

To make this work well you'd really need to override Read() and Write() for turfs. Basically, any of the map loading/saving libraries out there now take a lot of this stuff into account for you, so using one of them is the best way to go.
In response to Lummox JR
Lummox JR wrote:
Basically, any of the map loading/saving libraries out there now take a lot of this stuff into account for you, so using one of them is the best way to go.

I cant make saving a map with any of them I just can load a map and save that or save and make a password
In response to Lummox JR
Sort of hard to justify the way I did that with just that snippet. The reason I did z first is to divide them up into z layers. Also, I did a three dimensional list that way because I'm only saving turfs that have been altered, I don't save any of the default turfs into the list.

Once I have my list, I save them in a 3D fashion into the save file, but only the type paths, that way I don't have to save the turf object itself. When I load it, I use it's position in the savefile structure to know where the turf was positioned on the map, rather than reading an object, and I create a new turf in the specified location there. I wouldn't mind providing the actual system itself to you, Lummox, if you want to give me some feedback on it.
Please see the staff for assistance


EDIT: Oh... Man. This breaks areas. Don't use this. I'll just leave it here because I'm dangerously irresponsible. Also I know you aren't reading this, next person who comes along, copies this into your game, and then complains that it's broken.
In response to Ter13
If you'd like to see my implementation of map saving for an idea, send me a page 8)
Oh I'm reading a tutorial about saving the world, I think I will understand reading this.
Oh I'm reading a tutorial about saving the world, I think I will understand reading this.

Ummm... Hate to break it to you, but you shouldn't take the title so literally. If you are reading my saving tutorial, it only covers how savefiles work. You'll have to apply the concepts to world saving yourself.
In response to Ter13
Yes. I will apply the concepts to world.
But why save as:
F >> turfs
Takes a lot of cpu?
Loading and saving takes some time. For this reason, saving the entire world map is never recommended. Saving individual pieces that are meant to be modified, like player houses, makes more sense.
Did uh... You copy/paste the snippet from http://www.byond.com/forum/?post=2087694#comment19769771

This post?

If so... You know. Read. I'll just go ahead and tidy up. Loaded guns belong in safes.
In response to Ter13
I didin't copy and paste , I tested F << with objs and it works.
But you said the coode is break so I thought I should not try this theory
In response to Ter13
It seem saving and loading with "F" is more correct just have to offer your CPU.
It is possible to save lists then load then?
It seem saving and loading with "F" is more correct just have to offer your CPU.

What?

It is possible to save lists then load then?

Yes.
In response to Ter13
I mean if I save all turfs and all objects on the world it will lag a lot !

I'm a total newbie if it is talking about save and lists.
I can save and load them as this?
var/list/turfs = list (Chair,housefloor,door)
Page: 1 2