Kryzeth Standard Library

StdLib.Data.Space

supers: StdLib.Data

Wrapper for planet, space-location, and space-connection prototypes.

Methods14

function Space.get(object: table | string, object_type: nil | string, opts: {string, boolean} | nil) -> self

Internal helpers


Wraps or creates a space prototype. Overrides the standard Data:get function. Planets and space locations with orbit tables are extended via PlanetsLib interface.

function Space.__call(object: table | string, object_type: nil | string, opts: {string, boolean} | nil) -> self
function Space.set_distance(distance: number) -> self

Space positional functions


Sets this location's distance. Updates orbit.distance when an active orbit exists.

function Space.update_distance(delta: number) -> self

Adds a value to this location's current distance. Uses orbit.distance when an active orbit exists, otherwise uses the base distance field.

function Space.copy_distance(other: StdLib.Data.Space) -> self

Copies another location's effective distance to this location. The source and destination independently use orbit.distance or distance.

function Space.set_orientation(orientation: number) -> self

Sets this location's orientation. Updates orbit.orientation through PlanetsLib when an active orbit exists.

function Space.set_position(distance: number, orientation: number) -> self

Sets this location's distance and orientation fields simultaneously. Updates orbit.distance and orbit.orientation through PlanetsLib when an active orbit exists.

function Space.copy_position(other: StdLib.Data.Space) -> self

Copies another location's effective distance and orientation. Source and destination independently use orbit fields or base fields.

function Space.remove_from_asteroid_spawn_definition(asteroid: string) -> nil

Asteroid spawn management


Removes an asteroid from this prototype's spawn definitions.

Parameters
asteroidstring

Asteroid prototype name

Returns
nil
function Space.add_asteroid_spawn_definition(asteroid: table) -> nil

Adds an asteroid spawn definition to this prototype.

Parameters
asteroidtable

Asteroid spawn definition

Returns
nil
function Space.get_asteroid_spawn_definitions() -> asteroid_spawn_definitions table[] | nil

Returns a copy of this prototype's asteroid spawn definitions.

function Space.clear_asteroid_spawn_definitions() -> cleared boolean

Removes all asteroid spawn definitions from this prototype.

function Space.copy_asteroid_spawn_definitions(copy_name: string, type_name: string) -> nil

Copies asteroid spawn definitions from another space prototype.

Parameters
copy_namestring

Source prototype name

type_namestring

Source prototype type

Returns
nil
function Space.create_space_connection(destination: StdLib.Data.Space, length: nil | number) -> connection StdLib.Data.Space

Creates a space connection between this location and a destination.

Parameters
destinationStdLib.Data.Space

Destination planet or space location

lengthnil | number

Connection length; defaults to 15000

Returns
connectionStdLib.Data.Space

Fields6

Space.asteroid_spawn_definitions : table[] | nil

Asteroid spawn definitions

Space.distance : nil | number

Starmap distance

Space.orientation : nil | number

Starmap orientation

Space.orbit : StdLib.Data.Orbit | nil

Relative orbit added by PlanetsLib, generally used for moons

Space.__class: string = "Space"
Space.__index : unknown