Package openmw.nearbyΒΆ

openmw.nearby provides read-only access to the nearest area of the game world.

Can be used only from local scripts.

Usage:

local nearby = require('openmw.nearby')

Type nearby

nearby.COLLISION_TYPE

Collision types that are used in castRay.

nearby.activators

List of nearby activators.

nearby.actors

List of nearby actors.

nearby.castRay(from, to, options)

Cast ray from one point to another and return the first collision.

nearby.containers

List of nearby containers.

nearby.doors

List of nearby doors.

nearby.items

Everything that can be picked up in the nearby.

nearby.selectObjects(query)

Evaluates a Query.

Type COLLISION_TYPE

COLLISION_TYPE.Actor
COLLISION_TYPE.Default

Used by deafult: World+Door+Actor+HeightMap

COLLISION_TYPE.Door
COLLISION_TYPE.HeightMap
COLLISION_TYPE.Projectile
COLLISION_TYPE.Water
COLLISION_TYPE.World

Type RayCastingResult

RayCastingResult.hit

Is there a collision? (true/false)

RayCastingResult.hitNormal

Normal to the surface in the collision point (nil if no collision)

RayCastingResult.hitObject

The object the ray has collided with (can be nil)

RayCastingResult.hitPos

Position of the collision point (nil if no collision)

Type nearby

Field(s)

#COLLISION_TYPE nearby.COLLISION_TYPE

Collision types that are used in castRay.

Several types can be combined with '+'.

openmw.core#ObjectList nearby.activators

List of nearby activators.

openmw.core#ObjectList nearby.actors

List of nearby actors.

nearby.castRay(from, to, options)

Cast ray from one point to another and return the first collision.

Parameters

  • openmw.util#Vector3 from : Start point of the ray.

  • openmw.util#Vector3 to : End point of the ray.

  • #table options : An optional table with additional optional arguments. Can contain:
    ignore - an object to ignore (specify here the source of the ray);
    collisionType - object types to work with (see openmw.nearby#COLLISION_TYPE), several types can be combined with '+';
    radius - the radius of the ray (zero by default). If not zero then castRay actually casts a sphere with given radius.
    NOTE: currently ignore is not supported if radius>0.

Return value

#RayCastingResult:

Usages:

  • if nearby.castRay(pointA, pointB).hit then print('obstacle between A and B') end
  • local res = nearby.castRay(self.position, enemy.position, {ignore=self})
    if res.hitObject and res.hitObject ~= enemy then obstacle = res.hitObject end
  • local res = nearby.castRay(self.position, targetPos, {
        collisionType=nearby.COLLISION_TYPE.HeightMap + nearby.COLLISION_TYPE.Water,
        radius = 10,
    })
openmw.core#ObjectList nearby.containers

List of nearby containers.

openmw.core#ObjectList nearby.doors

List of nearby doors.

openmw.core#ObjectList nearby.items

Everything that can be picked up in the nearby.

nearby.selectObjects(query)

Evaluates a Query.

Parameter

Return value

openmw.core#ObjectList:

Type COLLISION_TYPE

Field(s)

#number COLLISION_TYPE.Actor
#number COLLISION_TYPE.Default

Used by deafult: World+Door+Actor+HeightMap

#number COLLISION_TYPE.Door
#number COLLISION_TYPE.HeightMap
#number COLLISION_TYPE.Projectile
#number COLLISION_TYPE.Water
#number COLLISION_TYPE.World

Type RayCastingResult

Result of raycasing

Field(s)

#boolean RayCastingResult.hit

Is there a collision? (true/false)

openmw.util#Vector3 RayCastingResult.hitNormal

Normal to the surface in the collision point (nil if no collision)

openmw.core#GameObject RayCastingResult.hitObject

The object the ray has collided with (can be nil)

openmw.util#Vector3 RayCastingResult.hitPos

Position of the collision point (nil if no collision)