block.raycast/entity.raycast: Updated docs to reflect changes

This commit is contained in:
REDxEYE 2024-08-20 15:33:29 +03:00
parent 1be50c2e06
commit a48d54aa27
4 changed files with 14 additions and 4 deletions

View File

@ -120,12 +120,17 @@ block.raycast(start: vec3, dir: vec3, max_distance: number, [optional] dest: tab
endpoint: vec3, -- point of the ray hit point endpoint: vec3, -- point of the ray hit point
iendpoint: vec3, -- position of the block hit by the ray iendpoint: vec3, -- position of the block hit by the ray
length: number, -- ray length length: number, -- ray length
normal: vec3 -- normal vector of the surface hit by the ray normal: vec3, -- normal vector of the surface hit by the ray
[optional] dest: table, -- table where result will be written to instead of function return
[optional] filter: table -- list of block names that are "transparent" for ray
} or nil } or nil
``` ```
Casts a ray from the start point in the direction of *dir*. Max_distance specifies the maximum ray length. Casts a ray from the start point in the direction of *dir*. Max_distance specifies the maximum ray length.
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 function returns a table with the results or nil if the ray does not hit any block. 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. The result will use the destination table instead of creating a new one if the optional argument specified.

View File

@ -51,7 +51,7 @@ entities.get_all_in_radius(center: vec3, radius: number) -> array<int>
```lua ```lua
entities.raycast(start: vec3, dir: vec3, max_distance: number, entities.raycast(start: vec3, dir: vec3, max_distance: number,
ignore: int, [optional] destination: table) -> table or nil ignore: int, [optional] destination: table, [optional] filter: table) -> 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. 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.

View File

@ -65,12 +65,17 @@ block.raycast(start: vec3, dir: vec3, max_distance: number, [опциональ
endpoint: vec3, -- точка касания луча endpoint: vec3, -- точка касания луча
iendpoint: vec3, -- позиция блока, которого касается луч iendpoint: vec3, -- позиция блока, которого касается луч
length: number, -- длина луча length: number, -- длина луча
normal: vec3 -- вектор нормали поверхности, которой касается луч normal: vec3, -- вектор нормали поверхности, которой касается луч
[optional] dest: table, -- таблица куда будет записан результат вместо возврата из функции
[optional] filter: table -- массив имён блоков которые "прозрачны" для луча
} или nil } или nil
``` ```
Бросает луч из точки start в направлении dir. Max_distance указывает максимальную длину луча. Бросает луч из точки start в направлении dir. Max_distance указывает максимальную длину луча.
Аргумент `filter` позволяет указать какие блоки являются "прозрачными" для луча, прим.: {"base:glass","base:water"}.
Для использования агрумент `dest` нужно чем-то заполнить(можно nil), это сделано для обратной совместимости
Функция возвращает таблицу с результатами или nil, если луч не касается блока. Функция возвращает таблицу с результатами или nil, если луч не касается блока.
Для результата будет использоваться целевая (dest) таблица вместо создания новой, если указан опциональный аргумент. Для результата будет использоваться целевая (dest) таблица вместо создания новой, если указан опциональный аргумент.

View File

@ -51,7 +51,7 @@ entities.get_all_in_radius(center: vec3, radius: number) -> array<int>
```lua ```lua
entities.raycast(start: vec3, dir: vec3, max_distance: number, entities.raycast(start: vec3, dir: vec3, max_distance: number,
ignore: int, [optional] destination: table) -> table или nil ignore: int, [optional] destination: table, [optional] filter: table) -> table или nil
``` ```
Функция является расширенным вариантом [block.raycast](libblock.md#raycast). Возвращает таблицу с результатами если луч касается блока, либо сущности. Функция является расширенным вариантом [block.raycast](libblock.md#raycast). Возвращает таблицу с результатами если луч касается блока, либо сущности.