OPX//77
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? }; errors invalid_from, invalid_to, invalid_options
Example
local ray = Lib.World.Ray(eye, target, { static = true })
if ray.ok and ray.value.hit then print(ray.value.distance) end

Lib.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).
  • filter?: string | table | number

Returns

  • Result — rows; error invalid_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; errors invalid_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; error invalid_position

On this page