Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
component:geolyzer:zh [2023/11/05 08:41]
hfsr created
component:geolyzer:zh [2023/12/10 16:30] (current)
hfsr [组件:地址分析仪]
Line 1: Line 1:
-Component: Geolyzer+组件:地址分析仪
 ================= =================
-This component is provided by the [[block:​geolyzer|geolyzer block]]. +此组件由[[block:​geolyzer:zh|地址分析仪方块]]提供。  ​ 
- +   
-Component name: `geolyzer`  +组件名:`geolyzer`。   
-Callbacks:+   
 +回调函数:
  
 - `scan(x:​number,​ z:number[, y:number, w:number, d:number, h:number][, ignoreReplaceable:​boolean|options:​table]):​table`  ​ - `scan(x:​number,​ z:number[, y:number, w:number, d:number, h:number][, ignoreReplaceable:​boolean|options:​table]):​table`  ​
-  ​Analyzes the density of an area at the specified relative coordinates ​`x``z` and `y`. This will return a list of hardness values for the blocks in the specified range. The coordinates are relative to the location of the geolyzer. Size of the analyzed area can be optionally given with parameters ​`w``d` and `h` which stand for widthdepth and height, otherwise the area is assumed to be a single block at the specified offset.+  ​分析位于`x``z``y`指定的相对坐标处一定区域的密度。此函数将会返回一个列表,其中包含指定范围内方块的硬度值。提供的坐标是以地址分析仪为参考点的相对坐标。待分析区域的大小由参数`w``d``h`指定,分别代表宽度(width)、深度(depth)与高度(height)。若不指定大小则认为区域为指定坐标对应的单个方块。  ​
   ​   ​
-  ​Hardness values for blocks further away from the geolyzer are more noisy than those for blocks nearby. The exact formula for calculating how much a single value can deviate from the real hardness value of a specific block is: `euclidean distance to block * 1/33 * geolyzerNoisewhere `geolyzerNoise` ​is a mod config option with a default value of `2`.+  ​方块离地址分析仪越远,扫描到的硬度值所含的噪声就会越大。计算某个值与特定方块实际硬度值偏离程度的准确公式是:`到方块的欧几里得距离 ​* 1/33 * 地质分析仪噪声`,公式中的`地质分析仪噪声(geolyzerNoise`常数可通过配置文件修改,默认为`2`。  ​
   ​   ​
-  ​Table with multiple results is linear, but results represent an area in a 3D world. Area starts at a block defined by offset from the geolyzer block (`x``z` and `y`), and size (`w``d` and `h`) defines how many blocks it extends towards respectively:​ positive ​x, positive ​and positive ​coordinates. To figure out what elements in results table correspond to which coordinates,​ it should be interpreted as follows: ​ +  ​包含多个结果的表中的数据是线性的,但是结果所代表的是一个3D的区域。区域起始于由相对于地址分析仪的相对坐标(`x``z``y`)定义的方块,其大小(`w``d``h`)决定了区域分别在坐标轴的x轴正方向、z轴正方向和y轴正方向上延伸的方块数。将结果表中的元素与坐标对应起来需要用到以下方法: ​  
-  ​first, values go towards positive ​x, then towards positive ​z, then towards positive ​y. In other words, if the result was a 3D nested table which got converted to a linear table, innermost table would contain values going in the positive ​direction, middle table going in the positive ​direction, and the outermost going in the positive ​direction. See the code snippet at the bottom for an example. +\\ 
- +  ​表中元素首先沿x轴正方向排列,然后是z轴正方向,最后是y轴正方向。换言之,假设结果表是将三维表转化成一维表得到的,那么三维表的最后一维中是按照x轴正方向排列的数值,中间一维是按照z轴正方向排列的,最高一维是按照y轴正方向排列的。可查看底部的一段代码样例以帮助理解。  ​ 
- **Note** that the offset is always absolute in terms of facing direction. In other words if the geolyzer is installed in a robot, offset won't be affected by the robot'​s facing. +\\ 
- + **注意:**偏移量在方向上是绝对的,不受面向方向的影响。换句话说,如果地质分析仪安装在机器人中,偏移量不会受到机器人朝向的影响。  ​ 
- **Note** that the amount of values returned is always ​64, even if the scan volume is only part of that. If 10 blocks are scanned, the first 10 values in the result represent those blocks scanned. The remaining values in the result should be ignored. + **注意:**返回的数值一定为64个,即使扫描区域的体积不足64也是如此。假设扫描了10个方块,那么扫描结果中的前10个值就代表了被扫描的方块,而扫描结果中剩下的值应当被忽略。  ​ 
 +\\
 - `analyze(side:​number[,​ options:​table]):​table`  ​ - `analyze(side:​number[,​ options:​table]):​table`  ​
-  ​Get some information on a directly adjacent block. By default the returned table returns the string ​ID of the block (e.g. `minecraft:​dirt`, metadata, hardness and some more information). Note that a single call to this consumes the same amount of energy a call to `scan` ​does!   +  ​获取某个直接接触地址分析仪的方块的信息。默认情况下返回的表中将包含字符串格式的方块ID(如`minecraft:​dirt`、元表、硬度以及一些其他信息)请注意调用一次该函数消耗的能量与调用`scan`函数相同! ​  
-  ​This method can be disabled with the `misc.allowItemStackInspection` ​setting in the config.+  ​此方法可通过配置文件中的`misc.allowItemStackInspection`设置项禁用。 ​  
 +\\
 - `store(side:​number,​ dbAddress:​string,​ dbSlot:​number):​boolean`  ​ - `store(side:​number,​ dbAddress:​string,​ dbSlot:​number):​boolean`  ​
-  ​Stores an item stack representation of the block on the specified side of the geolyzer to the specified slot of a [[component:​database|database component]] with the specified address. Do not expect this to work (well) for every block in existence, in particular not for mod's blocks that are differentiated by NBT data (such as robots).+  ​读取与地址分析仪指定面接触的方块信息,并将其以物品堆的形式存储到指定地址对应的[[component:​database:zh|数据库组件]]中的指定槽位。此函数不一定能(很好的)处理所有方块,尤其是以NBT数据区分的模组方块(例如机器人)。 ​  
 +\\
 - `detect(side:​number):​boolean,​ string`  ​ - `detect(side:​number):​boolean,​ string`  ​
-  ​Same as `robot.detect` ​(from the robot component). Detects the block on the given side, relative to the robot, and returns whether or not the robot can move into the block, as well as a general description of the block. ​  +  ​`robot.detect`(来自机器人组件)相同。探测指定方向的方块,方向是机器人的相对方向,并返回机器人可否移动到此方块的位置中,同时给出方块的大体描述。 ​  
-**Returns:** `true` ​if the robot if whatever is in front of the robot would prevent him from moving forward (a block or an entity) (Note: Drones return ​`trueeven if the block is `passable`), `false` ​otherwise. The second parameter describes what is in front in general and is one of either ​`entity``solid``replaceable``liquid``passable` ​or `air`. +**返回值:**若机器人前方的物体会阻碍机器人移动(为方块或实体)则返回 ​`true`(注意:无人机即使在方块为`passable`时也会返回`true`),在其他情况下会返回`false`。第二个参数大体描述了遣返的物体,取值可能为下列之一:`entity``solid``replaceable``liquid``passable``air`。   
-- `canSeeSky():​boolean` ​Returns whether there is a clear line of sight to the sky directly above. Transparent blocks, e.g. glass don't affect the line of sight. +\\ 
-- `isSunVisible():​boolean` ​Returns whether the sun is currently visible directly above. The result is affected by possible blocks blocking the line of sight directly above (which can be checked with `canSeeSky()`) and whether it's night or day.+- `canSeeSky():​boolean` ​  
 +  返回从当前位置垂直向上是否能看到天空。透明方块,例如玻璃,不会影响视线。 ​  
 +\\ 
 +- `isSunVisible():​boolean` ​  
 +  返回从当前位置垂直向上是否能看到太阳。结果受到正上方能阻碍视线的方块(可由`canSeeSky()`函数检查)以及当前为白天还是黑夜影响。 ​  
 +\\
  
-Following code snippet can be used to get a grasp of how the `scan` ​function works in practice. It scans an area of specified size at a specified offset, saves the returned data along with correct offsets from the geolyzer block (or robot) and prints those.+下列代码片段可用于理解`scan`函数实际如何工作。它会扫描指定偏移处指定大小的区域,保存返回的数据以及相对于地质分析仪方块(或机器人)的准确偏移坐标,并打印这些数据。
  
 <code Lua> <code Lua>
Line 49: Line 57:
     for z = 0, sizez - 1 do     for z = 0, sizez - 1 do
         for x = 0, sizex - 1 do         for x = 0, sizex - 1 do
-            -- alternatively when thinking in terms of 3-dimensional table: ​map[offsety + y][offsetz + z][offsetx + x] = scanData[i]+            -- 可看作是三维表:map[offsety + y][offsetz + z][offsetx + x] = scanData[i]
             map[i] = {posx = offsetx + x, posy = offsety + y, posz = offsetz + z, hardness = scanData[i]}             map[i] = {posx = offsetx + x, posy = offsety + y, posz = offsetz + z, hardness = scanData[i]}
             i = i + 1             i = i + 1