add "include_non_selectable" parameter to blocks raycast

This commit is contained in:
clasher113 2026-01-05 23:05:47 +02:00
parent ce769143f8
commit 8f1739c85b
10 changed files with 57 additions and 23 deletions

View file

@ -136,7 +136,9 @@ Set specified bits.
## Raycast
```lua
block.raycast(start: vec3, dir: vec3, max_distance: number, [optional] dest: table, [optional] filter: table) -> {
block.raycast(start: vec3, dir: vec3, max_distance: number, [optional] dest: table,
[optional] filter: table, [optional] include_non_selectable = false
) -> {
block: int, -- block id
endpoint: vec3, -- point of the ray hit point
iendpoint: vec3, -- position of the block hit by the ray
@ -150,6 +152,9 @@ Casts a ray from the start point in the direction of *dir*. Max_distance specifi
Argument `filter` can be used to tell ray what blocks can be skipped(passed through) during ray-casting.
To use filter `dest` argument must be filled with some value(can be nil), it's done for backwards compatability
The `include_non_selectable` argument determines whether blocks that cannot be selected by the cursor will be included.
Example - `base:water`
The function returns a table with the results or nil if the ray does not hit any block.
The result will use the destination table instead of creating a new one if the optional argument specified.

View file

@ -63,8 +63,9 @@ entities.get_all_in_radius(center: vec3, radius: number) -> array<int>
```
```lua
entities.raycast(start: vec3, dir: vec3, max_distance: number,
ignore: int, [optional] destination: table, [optional] filter: table) -> table or nil
entities.raycast(start: vec3, dir: vec3, max_distance: number, ignore: int, [optional] destination: table,
[optional] filter: table, [optional] include_non_selectable = false
) -> table or nil
```
The function is an extended version of [block.raycast](libblock.md#raycast). Returns a table with the results if the ray touches a block or entity.