ID:244738
 
Keywords: maps, swap
(See the best response by Chowder.)
Alright, I'm trying to play around with swap maps to create custom dungeons on a player by player level. I can create my dungeon, but I cannot seem to figure out swap maps. How do I get the map to save?

mob
verb
SaveMap(map as text)
if(!map) map=input("Map name","Map name") as text
if(!SwapMaps_Save(map))
usr << "Map [map] not found."
else
usr << "Map [map] saved."

proc/SwapMaps_Save(id)
InitializeSwapMaps()
var/swapmap/M=swapmaps_byname[id]
if(M) M.Save()
return M


Always returns that the map was not found. I'm no expert programmer but I believe I've got a competent grasp of what I'm doing I'd hope. Attempting to read the help file doesn't really...well help.
Best response
I looked at the demo for swapmaps, and I think this is what your looking for.
        SaveChunk()
if(!loc)
usr << "You must be on the map to save a chunk with this demo."
return
var/_x=round(input("x size:","New map: x size",world.maxx) as num,1)
var/_y=round(input("y size:","New map: y size",world.maxy) as num,1)
_x=max(1,min(_x,world.maxx-x+1))
_y=max(1,min(_y,world.maxy-y+1))
SwapMaps_SaveChunk("chunk",loc,locate(x+_x-1,y+_y-1,z))
Save Chunk...saves exactly what it says: A CHUNK. I need a full map saved which is what I assumed Save Map did but no matter what I try using the demo I can't get it to save the map. I mean once I get it working in the demo it can be adapted to what I need it for, but until I can at-least find out how to save the map there's nothing I can do.

[edit] I stand corrected....Apparently one must first Build map, then save the map. As unusual as that sounds you must first build a new /swapmap dantum. I guess I just didn't think? Well I'll continue to try at this to see what works. [/edit]

[edit2] Uh...using the demo, you must first 'build map' then 'save map' but building a map, placing an object, then saving said map exiting, then proceeding to reload the map does not actually save anything...in fact I cannot tell if it does anything at all. Although I really do not need to save and load maps I do need to dynamically create them so I believe I may just be able to get away without saving them.[/edit2]
Well, my goal here was as follows.

1.) Enter turf entered is called (Got that working quite simply)
2.) Enter creates new map. (Took the longest time to try to load a map off enter, so I went with create a new one)
3.) Generator creates new dungeon. (Did that simply)
4.) ???
5.) Profit! (Aka an explorable custom created dungeon on a new map that can be deleted once they complete it, or they leave as to not take up resources)
In response to King killer 113711
King killer 113711 wrote:
Well, my goal here was as follows.

1.) Enter turf entered is called (Got that working quite simply)
2.) Enter creates new map. (Took the longest time to try to load a map off enter, so I went with create a new one)
3.) Generator creates new dungeon. (Did that simply)
4.) ???
5.) Profit! (Aka an explorable custom created dungeon on a new map that can be deleted once they complete it, or they leave as to not take up resources)

It sounds like the Map Instancing library will do most of what you need. It has a demo that shows how to create new maps when a player enters the dungeon - it creates a new z level and makes a copy of an existing map for the player entering the dungeon.

The other thing you'd need, which is a separate thing, is to generate custom dungeons. Once you create a new z level for the dungeon you'd run a proc that generates walls to create a custom dungeon.