Space

by Kaiochao
Spaces on the map that can be duplicated, allocated, and stored. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Kaiochao.Space##version=2

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Kaiochao.Space##version=2

34 downloads
Version Latest
Date added: May 19 2019
Last updated: May 20 2019
0 fans
atom/SavesToSpace()
Override this to return TRUE if you want this atom to be saved to spaces.
FALSE if you want it to be ignored, not duplicated, not saved.
Defaults to FALSE.

space


A space of turfs on the map.
Map data can be duplicated to anywhere.
Spaces can be saved and loaded via savefiles.

Create from two corner turfs
New(turf/corner1, turf/corner2)

Create from a list containing turfs
New(list/turfs)

Create by copying another space's turfs
New(space/space)

Properties
SetCorners(turf/corner1, turf/corner2)
LowerCorner() (turf at min coordinates)
UpperCorner() (turf at max coordinates)

SetTurfs(list/turfs)
Turfs() (turfs in the space)

Width() (x tile span)
Height() (y tile span)
Depth() (z tile span)

Storage overrides
Write(savefile/save) (called by savefile << space)
Read(savefile/save) (called by savefile >> space)

Duplication methods
Copy() (copy data from the map in preparation for paste)
Paste(turf/lower) (paste copied data)
Duplicate(turf/lower) (copy then paste)

Helper methods
Locate(x, y, z) (get a turf by relative coordinates)
Contains(atom/atom) (check if an atom is in the space)
FindWithTag(tag) (get the first atom in the space with the matching tag)

universe


Contains and allocates new spaces to avoid overlapping.

Allocating new spaces
Allocate(width, height, depth)
Allocate(space/space)

This lets you create a new space of a given size that doesn't overlap any spaces in a universe. This is useful when loading spaces from savefiles or creating new empty spaces where you don't care where they end up, as long as they're not overlapping any other spaces in this universe.

Opening and Closing spaces
Open(space)
universe -= space

Close(space)
universe += space

Spaces allocated in a universe are closed off to that universe.
Closed spaces won't be overlapped by allocation.
Open spaces can be overlapped.

Pasting loaded spaces
Paste(space)

When a space is loaded from a savefile, it doesn't exist on the map yet, but it contains copied data that can be pasted into the world. If you don't care where the space ends up, you can paste it in a universe for it to be pasted anywhere in the world without overlapping any closed spaces.

space_storage


Represents a place in the file system to store spaces by name.

Create at a path
New(path = "Spaces")

Spaces will be saved and loaded by name relative to this path.

Naming
Name(name, space/space)

Remove(space/space)
Remove(name)

Names()
Spaces()

Lookup(name) (get a space by name)
NameOf(space/space) (get a name by space)

Saving and Loading
Save(space/space)
Save(name)

Load(name)

CanLoad(name) (does the file exist?)
Filename(name) (path to the savefile for this name)
Savefile(name) (the /savefile instance for this name)
</<>