Skip to main content

Vec2

The Vector3 Module for the Addon API!


Functions

new

'lua sm.scrapcomputers.vector2.new( x, y ) '

Creates a new 2D vector with specified x and y values.

Arguments:

  • x [ number ] The X value of the vector.
  • y [ number ] The Y value of the vector.

Returns:

  • [ Vector2 ] A new vector2 instance.

convertIfNeeded

sm.scrapcomputers.vector2.convertIfNeeded( input, nilAllowed )

Converts an input into a Vector2 if needed. If the input is already a Vector2, it returns it; otherwise, it tries to convert from a table.

Arguments:

  • input [ ScVec2|table ] The input that might be a Vector2 or a table representing it.
  • nilAllowed [ boolean ] Whether nil is allowed as a valid input.

Returns:

  • [ Vector2 ] The converted Vector2, or nil if allowed and the input is nil.