CC: LiDAR
此模组添加了一个方块:LiDAR 传感器。LiDAR 传感器让 ComputerCraft 计算机能够通过发射大量射线并检测其击中方块后的返回信号,从而“看到”前方的世界。

用法
将 LiDAR 传感器连接到任意计算机,然后运行 lidartest 命令以查看该传感器功能的演示。你可以自由运行 lidartest --help 以查看更多选项。
当你准备好在程序中使用该传感器时,像往常一样包装(wrap)外围设备,并使用以下方法进行交互:
lidar.setRotationPeriod(period):设置水平扫描从视场(FOV)一端到另一端所需的游戏刻数,较低的周期意味着更快的扫描速度。低于 2 的周期将停止扫描。
lidar.setHorizontalFov(fov):(角度)调整传感器水平扫描的幅度。
lidar.setVerticalFov(fov):(角度)调整射线列的幅度。
lidar.setRange(range):射线在击中目标前能行进的最大距离(以方块为单位)。
lidar.setIgnoreFluids(ignore):如果设置为 true,射线将穿透水等流体,转而击中其后方的方块。
lidar.setBackAndForth(enable):默认情况下,传感器将从左向右扫描,然后从右向左扫描并重复。可以将其更改为从左向右扫描,然后跳回左侧并重复。
lidar.setShowLaser(show):如果设置为 true,将显示传感器视场锥体的可视化效果。
lidar.getCurrentAngle():返回传感器当前注视的角度(不推荐使用,请参阅 test)。
lidar.test(rayCount, [detail]):这是 LiDAR 传感器的主要方法,它将沿当前扫描角度水平对齐地发射一列射线。
- 参数:
rayCount:要发射的射线数量。数量越高,分辨率越高,但对性能的影响也越大。
detail:控制返回信息的整数。
- 返回一个
table:
horizontalAngle:发射此列射线时的扫描角度(以度为单位)。概念上等同于 lidar.getCurrentAngle(),但该函数有 1 个游戏刻的延迟,因此在调用 test 后调用它将返回错误的值。
rays:包含 rayCount 个条目的数组,每个条目为 nil(如果射线未击中任何物体)或类似以下的 table:
verticalAngle:相对于水平面,发射此射线的垂直角度(以度为单位)。
distance:射线在击中表面前行进的距离。
- 如果
detail == 1,此表还包含:
name:被击中方块的键名。
state:被击中方块的状态。
- 如果
detail == 2,此表还包含所有在此处描述的信息。
性能
该外围设备使用射线投射(raycasts)实现,计算成本相当高。它很容易导致服务器 TPS 下降,因此我建议不要将此模组添加到公共服务器中,或者至少使用提供的配置值限制传感器的功能。
集成
- Create:可以使用扳手旋转 LiDAR 传感器
- Sable (Create Aeronautics):当在子层级(sublevel)内使用时,LiDAR 传感器正常工作,并能检测到其他子层级中的方块
CC: LiDAR
This mod adds a single block: the LiDAR Sensor. LiDAR sensors give ComputerCraft computers the ability to see the world in front of them by firing a bunch of rays and detecting their return when they hit blocks.

Usage
Attach a LiDAR Sensor to any computer, then run the lidartest command to see a demo of what the sensor can do. Feel free to run lidartest --help to see more options.
When you're ready to integrate the sensor in your program, wrap the peripheral as usual and use the following methods to interact with it:
lidar.setRotationPeriod(period): sets how many ticks the horizontal sweep from one end of the FOV to the other will take, a lower period means a faster sweep. A period lower than 2 will stop the sweep.
lidar.setHorizontalFov(fov): (degrees) adjusts the amplitude of the sensor's horizontal sweep.
lidar.setVerticalFov(fov): (degrees) adjusts the amplitude of the column of rays.
lidar.setRange(range): maximum distance in blocks that a ray will travel.
lidar.setIgnoreFluids(ignore): if set to true, rays will go through fluids such as water and will instead hit the blocks behind it.
lidar.setBackAndForth(enable): by default the sensor will sweep left to right, then right to left and repeat. This can be changed to instead go left to right, then jump back to left and repeat.
lidar.setShowLaser(show): if set to true, a visualization of the sensor's FOV cone will be shown.
lidar.getCurrentAngle(): returns the angle that the sensor is currently looking at (not recommended, see test).
lidar.test(rayCount, [detail]): this is the main method of the LiDAR Sensor, it will fire a column of rays aligned horizontally to the current sweep angle.
- Arguments:
rayCount: number of rays to be shot. A higher amount will result in a higher resolution but also a higher performance impact.
detail: integer that controls the information that is returned.
- Returns a
table:
horizontalAngle: the sweep angle (in degrees) at which this column of rays was fired. Equivalent in concept to lidar.getCurrentAngle(), however that function has a 1-tick delay so it will return an incorrect value if called after test.
rays: an array of rayCount entries, where each is nil (if the ray didn't hit) or a table like:
verticalAngle: vertical angle (in degrees) at which this ray was fired with respect to the horizontal plane.
distance: distance that the ray traveled before hitting a surface.
- If
detail == 1, this table additionally contains:
name: the hit block's key.
state: the hit block's state.
- If
detail == 2, this table additionally contains all information described here.
Performance
The peripheral is implemented using raycasts, which are quite computationally costly. It can easily degrade TPS in a server, so I would advise not to add this mod to public servers or at the very least limit what the sensor can do using the provided configuration values.
Integrations
- Create: the LiDAR Sensor can be rotated using the wrench
- Sable (Create Aeronautics): the LiDAR sensor works when used inside a sublevel and can detect blocks in other sublevels
评论 0
登录后参与评分
还没有评论,来抢沙发吧