mirror of
https://github.com/goonstation/goonstation-2020.git
synced 2026-08-24 04:26:15 +01:00
101 lines
4.5 KiB
Plaintext
101 lines
4.5 KiB
Plaintext
|
|
|
|
/*-- About ---------------------------------------------------------------------
|
|
|
|
DMM Suite Version 2.0, Released February 16th, 2018
|
|
By Iain Peregrine with code from BYOND://Forum_account.Text
|
|
|
|
The dmm_suite provides saving and loading of map files in BYOND's native DMM
|
|
map format. It approximates the map saving and loading processes of the Dream
|
|
Maker and Dream Seeker programs so as to allow editing, saving, and loading
|
|
of maps at runtime.
|
|
|
|
------------------------
|
|
|
|
To save a map at runtime, create an instance of /dmm_suite, and then call one
|
|
of the writing functions, as outlined individually below. The text returned
|
|
can then be saved to file or cloned to a different portion of the map using
|
|
read_map.
|
|
|
|
To load a map at runtime, create an instance of /dmm_suite, and then call
|
|
read_map, as outlined below. Note that if you wish to load a map onto a
|
|
z-level that already has objects on it, you will have to handle the removal
|
|
of those objects. Otherwise the new map will simply load the new objects on
|
|
top of the old ones.
|
|
|
|
------------------------
|
|
|
|
For best results:
|
|
|
|
- If a var doesn't need to be saved, make it a tmp variable: var/tmp/not_saved
|
|
- Don't use "turf stacking" when editing maps. Use objs as overlays instead.
|
|
- Always call the parent proc ..() when redefining New() on any atomic type.
|
|
- Save different portions of the map as individual chunks. Also, saving z
|
|
levels as different maps will reduce save / load time.
|
|
- Maps saved using the dmm_suite will contain a "comments" object. Take care
|
|
not to delete this object when editing your maps, as the map will fail to
|
|
automatically load into its old position.
|
|
|
|
*/
|
|
//-- Reference -----------------------------------------------------------------
|
|
|
|
verb/read_map(dmm_text as text, coordX as num, coordY as num, coordZ as num)/*
|
|
Description:
|
|
Loads maps from DMM formatted text.
|
|
Arguments:
|
|
dmm_text: DMM formatted map text, as read from a file or as generated by write_map().
|
|
coordX/Y/Z: The coordinates at which to load the map. Defaults are as follows:
|
|
If the map was generated via write_map(), the coordinates of the map when saved.
|
|
Otherwise (1,1, world.maxz+1)
|
|
Returns: TRUE if successful, FALSE otherwise
|
|
*/
|
|
|
|
verb/write_map(turf/corner1, turf/corner2, flags as num)/*
|
|
Description:
|
|
Writes all contents of a region of turfs to a DMM formatted string. The region is
|
|
defined as all turfs within a rectangular prism where t1 and t2 are opposite corners.
|
|
Arguments:
|
|
t1: A turf representing one corner of a three dimensional grid (Required).
|
|
t2: Another turf representing the other corner of the same grid (Required).
|
|
flags: Any, or a combination, of several bit flags:
|
|
DMM_IGNORE_AREAS : Ignore /area instances while saving
|
|
DMM_IGNORE_TURFS : Ignore /turf instances while saving
|
|
DMM_IGNORE_OBJS : Ignore /obj instances while saving
|
|
DMM_IGNORE_MOBS : Ignore all mobs while saving
|
|
Equal to DMM_IGNORE_NPCS | DMM_IGNORE_PLAYERS
|
|
DMM_IGNORE_NPCS : Ignore /mob instances without attached players while saving
|
|
DMM_IGNORE_PLAYERS : Ignore /mob instances with attached players while saving
|
|
Returns: A DMM formatted string ready for saving to file or reading into to a different
|
|
location via read_map
|
|
*/
|
|
|
|
verb/write_area(area/save_area, flags as num)/*
|
|
Description: Writes all contents of the provided area to a DMM formatted string.
|
|
Arguments:
|
|
save_area: An area object to save.
|
|
flags: Any, or a combination, of several bit flags. See write_map.
|
|
Returns: A DMM formatted string ready for saving to file or reading into to a different
|
|
location via read_map
|
|
*/
|
|
|
|
verb/write_cube(startX as num, startY as num, startZ as num, width as num, height as num, depth as num, flags as num)/*
|
|
Descriptions:
|
|
Writes all contents of a region of turfs (defined by the provided arguments) to a
|
|
DMM formatted string.
|
|
Arguments:
|
|
startX/Y/Z: Coordinates representing the lower bound of the cube of turfs
|
|
to be written to map text.
|
|
width/height/depth: The total dimentions of the cube of turfs to be written to file.
|
|
flags: Any, or a combination, of several bit flags. See write_map.
|
|
Returns: A DMM formatted string ready for saving to file or reading into to a different
|
|
location via read_map
|
|
*/
|
|
|
|
verb/load_map(dmm_file as file, z_offset as num)/*
|
|
Deprecated: load_map has been deprecated. Use or read_map instead.
|
|
Arguments:
|
|
dmm_file: A .dmm file to load (Required).
|
|
z_offset: A number representing the z-level on which to start loading the map (Optional).
|
|
Returns: TRUE if successful, FALSE otherwise
|
|
*/
|