RaycastAPI

A global API which provides functions for raycasting

RaycastAPI.block

Raycasts a Block in the world.
If successful, returns the BlockState hit,
the exact world position hit as a Vector3, and the side of the block that was hit.
When unsuccessful,
returns nil.
blockCastType and fluidCastType determine how the raycast handles block shapes and fluids.
Will default to "COLLIDER" and "NONE" when nil
overload 1:
raycast:block(start, end, blockCastType, fluidCastType)
Method Property Fluent Description Representation
start accepts a Vector3
end accepts a Vector3
blockCastType accepts a String
fluidCastType accepts a String
Return Value a Varargs
overload 2:
raycast:block(startX, startY, startZ, end, blockCastType, fluidCastType)
Method Property Fluent Description Representation
startX accepts a Number
startY accepts a Number
startZ accepts a Number
end accepts a Vector3
blockCastType accepts a String
fluidCastType accepts a String
Return Value a Varargs
overload 3:
raycast:block(start, endX, endY, endZ, blockCastType, fluidCastType)
Method Property Fluent Description Representation
start accepts a Vector3
endX accepts a Number
endY accepts a Number
endZ accepts a Number
blockCastType accepts a String
fluidCastType accepts a String
Return Value a Varargs
overload 4:
raycast:block(startX, startY, startZ, endX, endY, endZ, blockCastType, fluidCastType)
Method Property Fluent Description Representation
startX accepts a Number
startY accepts a Number
startZ accepts a Number
endX accepts a Number
endY accepts a Number
endZ accepts a Number
blockCastType accepts a String
fluidCastType accepts a String
Return Value a Varargs

RaycastAPI.entity

Raycasts an Entity in the world
If successful, returns the EntityAPI hit and the exact world position hit as a Vector3.
When unsuccessful,
returns nil.
predicate is a function that prevents specific entities from being raycasted.
Takes in a single EntityAPI object.
Return true for valid entities, false for invalid.
Marks all entities as valid when nil
overload 1:
raycast:entity(start, end, predicate)
Method Property Fluent Description Representation
start accepts a Vector3
end accepts a Vector3
predicate accepts a function
Return Value a Varargs
overload 2:
raycast:entity(startX, startY, startZ, end, predicate)
Method Property Fluent Description Representation
startX accepts a Number
startY accepts a Number
startZ accepts a Number
end accepts a Vector3
predicate accepts a function
Return Value a Varargs
overload 3:
raycast:entity(start, endX, endY, endZ, predicate)
Method Property Fluent Description Representation
start accepts a Vector3
endX accepts a Number
endY accepts a Number
endZ accepts a Number
predicate accepts a function
Return Value a Varargs
overload 4:
raycast:entity(startX, startY, startZ, endX, endY, endZ, predicate)
Method Property Fluent Description Representation
startX accepts a Number
startY accepts a Number
startZ accepts a Number
endX accepts a Number
endY accepts a Number
endZ accepts a Number
predicate accepts a function
Return Value a Varargs

RaycastAPI.aabb

Raycasts based on a start position, an end position, and an array of Axis Aligned Bounding Boxes defined by the player.
AABBs are encoded as a table with indicies 1 and 2 being a Vector3.
`{vec(0,
0,0),vec(1,0.5,1)}` is a valid AABB, with `{ {vec(0,0,0),vec(1,0.5,1)}, {vec(0,0.5,0.5),vec(1,1,1)} }` being a valid AABB array.
This function returns the AABB table that was hit,
the exact position hit as a Vector3, the side of the AABB hit as a string or nil if inside an AABB, and the index of the AABB that was hit in the array
overload 1:
raycast:aabb(start, end, aabbs)
Method Property Fluent Description Representation
start accepts a Vector3
end accepts a Vector3
aabbs accepts a table
Return Value a Varargs
overload 2:
raycast:aabb(startX, startY, startZ, end, aabbs)
Method Property Fluent Description Representation
startX accepts a Number
startY accepts a Number
startZ accepts a Number
end accepts a Vector3
aabbs accepts a table
Return Value a Varargs
overload 3:
raycast:aabb(start, endX, endY, endZ, aabbs)
Method Property Fluent Description Representation
start accepts a Vector3
endX accepts a Number
endY accepts a Number
endZ accepts a Number
aabbs accepts a table
Return Value a Varargs
overload 4:
raycast:aabb(startX, startY, startZ, endX, endY, endZ, aabbs)
Method Property Fluent Description Representation
startX accepts a Number
startY accepts a Number
startZ accepts a Number
endX accepts a Number
endY accepts a Number
endZ accepts a Number
aabbs accepts a table
Return Value a Varargs
a a