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 |
nearby.activators |
List of nearby activators. |
nearby.actors |
List of nearby actors. |
nearby.asyncCastRenderingRay(callback, from, to) |
Asynchronously cast ray from one point to another and find the first visual intersection with anything in the scene. |
nearby.castRay(from, to, options) |
Cast ray from one point to another and return the first collision. |
nearby.castRenderingRay(from, to) |
Cast ray from one point to another and find the first visual intersection with anything in the scene. |
nearby.containers |
List of nearby containers. |
nearby.doors |
List of nearby doors. |
nearby.items |
Everything that can be picked up in the nearby. |
Type COLLISION_TYPE
COLLISION_TYPE.Actor | |
COLLISION_TYPE.AnyPhysical |
: World+Door+Actor+HeightMap+Projectile+Water |
COLLISION_TYPE.Camera |
Objects that should collide only with camera |
COLLISION_TYPE.Default |
Used by default: World+Door+Actor+HeightMap |
COLLISION_TYPE.Door | |
COLLISION_TYPE.HeightMap | |
COLLISION_TYPE.Projectile | |
COLLISION_TYPE.VisualOnly |
Objects that were not intended to be part of the physics world |
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.asyncCastRenderingRay(callback, from, to)
-
Asynchronously cast ray from one point to another and find the first visual intersection with anything in the scene.
Parameters
-
openmw.async#Callback callback
: The callback to pass the result to (should accept a single argument openmw.nearby#RayCastingResult). -
openmw.util#Vector3 from
: Start point of the ray. -
openmw.util#Vector3 to
: End point of the ray.
-
- 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: currentlyignore
is not supported ifradius>0
.
Return value
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, })
-
- nearby.castRenderingRay(from, to)
-
Cast ray from one point to another and find the first visual intersection with anything in the scene.
As opposite to
castRay
can find an intersection with an object without collisions. In order to avoid threading issues can be used only in player scripts only inonFrame
or in engine handlers for user input. In other cases useasyncCastRenderingRay
instead.Parameters
-
openmw.util#Vector3 from
: Start point of the ray. -
openmw.util#Vector3 to
: End point of the ray.
Return value
-
- 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.
Type COLLISION_TYPE
Field(s)
- #number COLLISION_TYPE.Actor
- #number COLLISION_TYPE.AnyPhysical
-
: World+Door+Actor+HeightMap+Projectile+Water
- #number COLLISION_TYPE.Camera
-
Objects that should collide only with camera
- #number COLLISION_TYPE.Default
-
Used by default: World+Door+Actor+HeightMap
- #number COLLISION_TYPE.Door
- #number COLLISION_TYPE.HeightMap
- #number COLLISION_TYPE.Projectile
- #number COLLISION_TYPE.VisualOnly
-
Objects that were not intended to be part of the physics world
- #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)