OSRS Plugin API
    Preparing search index...

    Class Vector2

    Represents a 2-dimensional vector.

    Index

    Constructors

    Properties

    x y

    Methods

    Constructors

    Properties

    x: number

    X-coordinate of the vector.

    -- Create a new Vector
    local vector = osrs.Vector2.new(10, 10)
    -- Print out the Vector's X
    osrs.print("X: " .. tostring(vector.x))
    y: number

    Y-coordinate of the vector.

    -- Create a new Vector
    local vector = osrs.Vector2.new(10, 10)
    -- Print out the Vector's Y
    osrs.print("Y: " .. tostring(vector.y))

    Methods

    • Sets the vector to the specified values.

      Parameters

      • x: number

        x value

      • y: number

        y value

      Returns Vector2

      reference to this vector, for chaining.

      -- Create a new Vector
      local vector = osrs.Vector2.new(10, 10)
      -- Print out the X and Y of the vector
      osrs.print("X: " .. tostring(vector.x) .. " Y: " .. tostring(vector.y))
      -- Change the x and y of the vecor using set
      vector:set(15, 5)
      -- Print out the X and Y of the vector
      osrs.print("X: " .. tostring(vector.x) .. " Y: " .. tostring(vector.y))
    • Instantiates a new Vector2.

      Parameters

      • Optionalx: number

        x value, or 0 if not set.

      • Optionaly: number

        y value, or 0 if not set.

      Returns Vector2

      the newly created Vector2.

      -- Create a new Vector
      local vector = osrs.Vector2.new(10, 10)