Area.Direction module

Functions for working with directions and orientations.

See also

Usage

local Direction = require('__stdlib__/stdlib/area/direction')

Functions

opposite(direction) Returns the opposite direction
next(direction[, eight_way=false]) Returns the next direction.
previous(direction[, eight_way=false]) Returns the previous direction.
to_orientation(direction) Returns an orientation from a direction.
to_vector(direction, distance) Returns a vector from a direction.

Fields

north defines.direction.north
east defines.direction.east
west defines.direction.west
south defines.direction.south
northeast defines.direction.northeast
northwest defines.direction.northwest
southeast defines.direction.southeast
southwest defines.direction.southwest

Functions

# opposite(direction)

Returns the opposite direction

Parameters: Returns:
# next(direction[, eight_way=false])

Returns the next direction.

For entities that only support two directions, see opposite.

Parameters:
  • direction : (defines.direction) the starting direction
  • eight_way : (boolean) true to get the next direction in 8-way (note: not many prototypes support 8-way) (default: false)
Returns:
# previous(direction[, eight_way=false])

Returns the previous direction.

For entities that only support two directions, see opposite.

Parameters:
  • direction : (defines.direction) the starting direction
  • eight_way : (boolean) true to get the previous direction in 8-way (note: not many prototypes support 8-way) (default: false)
Returns:
# to_orientation(direction)

Returns an orientation from a direction.

Parameters: Returns:
# to_vector(direction, distance)

Returns a vector from a direction.

Parameters: Returns:
  • (Position)

Fields

# north

defines.direction.north

# east

defines.direction.east

# west

defines.direction.west

# south

defines.direction.south

# northeast

defines.direction.northeast

# northwest

defines.direction.northwest

# southeast

defines.direction.southeast

# southwest

defines.direction.southwest