opx_lib
Lib.World
Last updated on
Raycasts, nearby objects and ground height.
Permission world.query.
Lib.World.Ray
Traces a ray and answers the nearest blocking surface.
Lib.World.Ray(from, to, options)Parameters
- from:
{ x, y, z } - to:
{ x, y, z } - options?:
{ static, dynamic, entities }
Returns
Result—{ hit, position, normal, material, distance, entity? }; errorsinvalid_from,invalid_to,invalid_options
local ray = Lib.World.Ray(eye, target, { static = true })
if ray.ok and ray.value.hit then print(ray.value.distance) endLib.World.Blocked
Whether the line between two points is blocked.
Lib.World.Blocked(from, to)Parameters
- from:
{ x, y, z } - to:
{ x, y, z }
Returns
boolean
Lib.World.Nearby
Every object around the local player, nearest first.
Lib.World.Nearby(radius, filter)Parameters
- radius:
number- Metres, over 0 up to 1000 (
World.MAX_RADIUS).
- Metres, over 0 up to 1000 (
- filter?:
string | table | number
Returns
Result— rows; errorinvalid_radius
Lib.World.Nearest
The closest object within a radius of the local player.
Lib.World.Nearest(radius, filter)Parameters
- radius:
number - filter?:
string | table | number
Returns
Result— one row; errorsinvalid_radius,not_found
Lib.World.GroundZ
The height of the static ground below a point.
Lib.World.GroundZ(position, options)Parameters
- position:
{ x, y, z } - options?:
table
Returns
Result—number; errorinvalid_position