OSRS Plugin API
    Preparing search index...

    Interface Camera

    This interface allows controlling the Camera through the Lua plugin system.

    interface Camera {
        clearTarget(): void;
        followTarget(): void;
        getLookAt(): FineCoord;
        getLookAtAngles(): Vector2;
        getPos(): FineCoord;
        hasTarget(): boolean;
        isControlled(): boolean;
        offsetLookAtAngles(offset: Vector2): void;
        setControl(allowControl: boolean): void;
        setLookAt(coord: FineCoord): void;
        setLookAtAngles(rot: Vector2): void;
        setPos(coord: FineCoord): void;
        targetNpc(id: number): void;
    }
    Index

    Methods

    • Clears the camera's target.

      Returns void

      osrs.Camera.clearTarget()
      
    • Sets the camera's look at position to be the position of the active target.

      Returns void

      function update()
      osrs.Camera.followTarget()
      return true
      end
      osrs.setInterval(update, 0, -1)
    • Gets the position that the camera is looking at.

      Returns FineCoord

      the look at position of the camera

      local lookAtPos = osrs.Camera.getLookAt()
      osrs.printf("Camera looking at position: X:%i Y:%i Z:%i\n", lookAtPos.x, lookAtPos.y, lookAtPos.z)
    • Gets the camera's angles around the look at position.

      Returns Vector2

      the pitch and yaw angles for the camera in degrees as a Vector2

      local rotation = osrs.Camera.getLookAtAngles()
      
    • Gets the position of the camera.

      Returns FineCoord

      the position of the camera

      local pos = osrs.Camera.getPos()
      osrs.printf("Camera position: X:%i Y:%i Z:%i", pos.x, pos.y, pos.z)
    • Returns if the camera has an active target or not.

      Returns boolean

      boolean representing whether or not the camera has an active target

      osrs.Camera.hasTarget()
      
    • Toggles the plugin camera control on and off.

      Returns boolean

      boolean representing whether plugin camera control is on or off

      osrs.Camera.isControlled()
      
    • Offsets the camera's angles around the look at position. The x (pitch) value is clamped to the range 22 (near ground) - 67 (top view) degrees. The y (yaw) value is in the range 0 - 360 degrees. The values (0, 90, 180, 270) represent facing (north, west, south, east) respectively.

      Parameters

      • offset: Vector2

        the pitch and yaw angle offsets to apply to the camera around the look at position as a Vector2

      Returns void

      local offset = osrs.Vector2.new(5, 90)
      osrs.Camera.offsetLookAtAngles(offset);
    • Toggles the plugin camera control on and off.

      Parameters

      • allowControl: boolean

        boolean representing whether to turn camera control on or off

      Returns void

      osrs.Camera.setControl(true)
      
    • Sets the position that the camera is looking at. Moves the camera as well, maintaining the original rotation around the look at.

      Parameters

      • coord: FineCoord

        the look at position of the camera

      Returns void

      local newCoord = osrs.MapCoord.new(1, 20, 44)
      osrs.Camera.setLookAt(newCoord:getFineCoordinate())
    • Sets the camera's angles around the look at position. The x (pitch) value is clamped to the range 22 (near ground) - 67 (top view) degrees. The y (yaw) value is in the range 0 - 360 degrees. The values (0, 90, 180, 270) represent facing (north, west, south, east) respectively.

      Parameters

      • rot: Vector2

        the pitch and yaw angles for the camera in degrees as a Vector2

      Returns void

      local newRot = osrs.Vector2.new(45, 90)
      osrs.Camera.setLookAtAngles(newRot);
    • Sets the position of the camera.

      Parameters

      • coord: FineCoord

        the position to set the camera

      Returns void

      local newCoord = osrs.MapCoord.new(1, 10, 10)
      osrs.Camera.setPos(newCoord:getFineCoordinate())
    • Sets the target of the camera to be the npc with the specified id.

      Parameters

      • id: number

        the id of the npc

      Returns void

      npcList = osrs.ClientOp.getNpcIdAll()
      osrs.Camera.targetNpc(npcList[1])