The library provides you with ways to easily make and manage copies of maps. Here's all you need to do to use it:
// make a copy of the second z level
var/Map/map = maps.copy(2)
world << "The new copy is on z level [map.z]."
// later on we call free() to make the z level available for other maps to use
makes a copy of a z level and returns a /Map object you can use to manage the map.
When you make a copy of a map, the library creates a "blueprint" of the original map. The blueprint is all you need to make a new copy, you can delete the original:
// make the blueprint for the dungeon
var/MapBase/dungeon = new(2)
// tell the library it can re-use the second a level
// later on, make an instance of the dungeon
var/Map/map = dungeon.make()
tells the library that you're done using a z level and it can use it the next time you ask it to copy a map. Because you've created the blueprint it doesn't matter if the original map is deleted.
You can also save and load these blueprints:
var/MapBase/base = new(2)
var/Map/map = maps.copy("dungeon.map")
You save the blueprint of the map, not an actual instance of the map. This lets you create copies of map that aren't compiled into the game's .dmb file. You create a copy of the saved map just like you create a copy of an existing z level, using the maps.copy() proc. The difference is that you pass it the filename.
Version 5 (posted 03-03-2012)
- Updated the library to make it work with the Region library. If you place a /region object on a map and copy the map, the copied turfs will be added to the region too.
- I removed the use_warp verb from the demos, now you automatically use the warp by stepping on it.
Version 4 (posted 02-15-2012)
- Changed the order of events when maps are created - the area of the turf is now set before the new turf is created, this way the turf's New() proc can check the type of its loc (the area).
- Removed the z var from the /MapBase object.
- Added the get() proc on the Map object which returns a list of all objects of the specified type on that map's z level.
- Added the reset() proc to the /Map object. This is similar to repop except it re-generates the entire map on the same z level. This not only restores deleted objects, but restores the initial state of each object and turf. There is an example of this in the demo called "demo".
- Added the atom.is_instanced() proc which returns 0 or 1. This is used by the library to determine which objects get stored in the MapBase object. You can override this proc to change which objects are saved. By default, all objects are stored except mobs with clients.
Version 3 (posted 10-12-2011)
Version 2 (posted 10-12-2011)
- Added saving and loading and a demo that shows how to use it - see saving-and-loading-demo\demo.dm
Version 1 (posted 10-11-2011)
- Added the maps.clear() proc to free up existing z levels (even ones that weren't dynamically created by the library).