Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
component:redstone:zh [2023/11/23 02:05]
hfsr [Component: Redstone]
component:redstone:zh [2023/12/27 03:18]
hfsr [组件:红石]
Line 3: Line 3:
 此组件由[[item:​redstone_card:​zh|红石卡]]提供。 此组件由[[item:​redstone_card:​zh|红石卡]]提供。
  
-1级红石卡仅支持MC原版红石功能(单路模拟红石信号)。2级红石卡提供与其他模组红石系统的联动(集束红石和无线红石)。对于集束红石,在Minecraft 1.12版本我们仅支持Project Red(红石计划),在更低版本我们支持:RedLogic、Project Red(1.1版本)、MineFactory Reloaded(我的工厂重制版)。无线红石方面支持以下模组:WR-CBE、SlimeVoid'​s WR。+1级红石卡仅支持MC原版红石功能(单路模拟红石信号)。2级红石卡提供与其他模组红石系统的联动(集束红石和无线红石)。对于集束红石,在Minecraft 1.12版本我们仅支持Project Red(红石计划),在更低版本我们支持:RedLogic、Project Red(1.1版本)、MineFactory Reloaded(我的工厂重制版)。无线红石方面支持以下模组:WR-CBE、SlimeVoid'​s WR。
  
 ===get*与set*方法重载=== ===get*与set*方法重载===
Line 24: Line 24:
   `getInput():​ table`  ​   `getInput():​ table`  ​
  
-返回当前输入的(非集束)红石信号值。`getInput(side)`会返回指定[[api:​sides:​zh|方向]]上的红石信号等级。`getInput()`会返回包含所有方向上红石信号等级的表。 +返回当前输入的(非集束)红石信号值。`getInput(side)`会返回指定[[api:​sides:​zh|方向]]上的红石信号等级。`getInput()`会返回包含所有方向上红石信号等级的表。 ​  
- +请注意返回的表的索引从0开始。因为表的索引其实是方向的原始值,`sides.bottom`对应了0。 ​  
-请注意返回的表的索引从0开始。因为表的索引其实是方向的原始值,`sides.bottom`对应了0。 +还需注意此函数用到的方向是相对于电脑而言的。即`sides.south`为**电脑的前方**,而不是世界的南方。类似还有`sides.left`为电脑的左侧,也就是如果你站在电脑面前的话,就是你的右侧。 ​ 
- +
-还需注意此函数用到的方向是相对于电脑而言的。即`sides.south`为**电脑的前方**,而不是世界的南方。类似还有`sides.left`为电脑的左侧,也就是如果你站在电脑面前的话,就是你的右侧。 +
 如果使用了例如RedLogic这样的模组,输入值可能会超出MC原版的[0,​ 15]范围。 如果使用了例如RedLogic这样的模组,输入值可能会超出MC原版的[0,​ 15]范围。
  
Line 61: Line 58:
 - `setOutput(side:​ number, value: number): number`  ​ - `setOutput(side:​ number, value: number): number`  ​
   `setOutput(values:​ table): table`  ​   `setOutput(values:​ table): table`  ​
- +设定要发出的红石信号强度。返回**旧的**值。配合支持的mod时可以为很大的值。此方法的参数为[[api:​sides:​zh|方向]]以及要应用到此方向的红石信号强度。`setOutput(values)`这种写法可以在一次调用内设定所有方向(或数个方向)上的红石信号强度。 ​  
-设定要发出的红石信号强度。返回**旧的**值。配合支持的mod时可以为很大的值。此方法的参数为[[api:​sides:​zh|方向]]以及要应用到此方向的红石信号强度。`setOutput(values)`这种写法可以在一次调用内设定所有方向(或数个方向)上的红石信号强度。 +\\
 - `getBundledInput(side:​ number, color: number): number`  ​ - `getBundledInput(side:​ number, color: number): number`  ​
   `getBundledInput(side:​ number): table`  ​   `getBundledInput(side:​ number): table`  ​
   `getBundledInput():​ table`  ​   `getBundledInput():​ table`  ​
- 
 和`getInput`类似,但适用于集束输入。读取指定[[api:​colors:​zh|颜色]]对应通道的值。  ​ 和`getInput`类似,但适用于集束输入。读取指定[[api:​colors:​zh|颜色]]对应通道的值。  ​
 **对OC 1.3而言:**仅可用于2级红石卡。  ​ **对OC 1.3而言:**仅可用于2级红石卡。  ​
-  ​ +  `getBundledInput(side,​ color)`返回指定方向上输入的指定颜色红石信号强度值。 ​  
-  ​`getBundledInput(side,​ color)` ​returns the strength of the incoming redstone value on the specified side on the specified color channel. ​  +  `getBundledInput(side)`返回一个表(格式为Map[Int, Int]这样的表结构),整合了指定方向上红石信号值,索引值为颜色。 ​  
-  `getBundledInput(side)` ​returns a table (Map[Int, Int] structure) of redstone values on the specified side in a bundled pack, indexed by color. ​  +  `getBundledInput()`返回所有的红石信号值,包括所有方向以及所有颜色。格式为Map[Int, Map[Int, Int]]这样的两层表结构。外层表的索引值范围是[0, 5],值为[[api:sides:zh|方向]](请记住`sides.bottom`为0)。每个方向对应内层表的数据结构与`getBundledInput(side)`返回值相同。  ​ 
-  `getBundledInput()` ​returns all redstone values, of all sides and all colors. It is a Map[Int, Map[Int, Int]] structure. The top level keys are in [0, 5] range, values of [[api:​sides|sides]] (keep in mind sides.bottom ​is zero). The child map of each side is the same data structure returned by `getBundledInput(side)`. +\\
 - `getBundledOutput(side:​ number, color: number): number`  ​ - `getBundledOutput(side:​ number, color: number): number`  ​
   `getBundledOutput(side:​ number): table`  ​   `getBundledOutput(side:​ number): table`  ​
   `getBundledOutput():​ table`  ​   `getBundledOutput():​ table`  ​
-  Like `getOutput`, but for bundled output, getting the values previously set that the device is emitting.\\ +类似`getOutput`,但是适用于集束输出。用于获取先前设定的输出值。 ​  
-  //As of OC 1.3: only available on a tier two redstone card.//+**对OC 1.3而言:**仅可用于2级红石卡。 ​  
 +\\
 - `setBundledOutput(side:​ number, color: number, value: number): number`  ​ - `setBundledOutput(side:​ number, color: number, value: number): number`  ​
-  Like `setOutput`, but for bundled output, setting the value for the channel with the specified ​[[api:​colors|API/Colors]]. Returns the previous values set. +类似`setOutput`,但是适用于集束输出。用于设定指定[[api:​colors:zh|颜色]]对应通道的输出值。返回之前设定的值。  ​ 
-  `setBundledOutput(side,​ values)` ​sets a pack of color-indexed redstone values, ​[0, 15]`colors.white` ​is zero. The values table doesn'​t have to be contiguous, and values omitted are left unchanged. +  `setBundledOutput(side,​ values)`设定一组红石信号值,以颜色为索引,颜色取值范围为[0, 15]`colors.white`为0。提供的值不一定要连续,省略的值将会保持不变。  ​ 
-  `setBundledOutput(values)` ​allows you to set redstone levels for any side and any color in a single api call.\\ +  `setBundledOutput(values)`让你能在单次API调用中修改所有方向上所有颜色的红石信号值。  ​ 
-  //As of OC 1.3: only available on a tier two redstone card.//+**对OC 1.3而言:**仅可用于2级红石卡。\\
  
 ```lua ```lua
Line 92: Line 87:
  
 - `getComparatorInput(side:​number):​number`  ​ - `getComparatorInput(side:​number):​number`  ​
-  ​Get the comparator input on the specified side.+  ​获取指定方向上的比较器输入。 ​  
 +\\
 - `getWirelessInput():​number`  ​ - `getWirelessInput():​number`  ​
-  ​Get the wireless redstone input.\\ +  ​获取无线红石输入值。 ​  
-  //Added in OC 1.3. Only available on tier two redstone cards.//+**自OC 1.3起添加:**仅可用于2级红石卡。\\ 
 +\\
 - `getWirelessOutput():​boolean`  ​ - `getWirelessOutput():​boolean`  ​
-  ​Get the wireless redstone output.\\ +  ​获取无线红石输出值。 ​  
-  //Added in OC 1.3. Only available on tier two redstone cards.//+**自OC 1.3起添加:**仅可用于2级红石卡。\\ 
 +\\
 - `setWirelessOutput(value:​boolean):​boolean`  ​ - `setWirelessOutput(value:​boolean):​boolean`  ​
-  ​Set the wireless redstone output.\\ +  ​设定无线红石输出值。 ​  
-  //Added in OC 1.3. Only available on tier two redstone cards.//+**自OC 1.3起添加:**仅可用于2级红石卡。\\ 
 +\\
 - `getWirelessFrequency():​number`  ​ - `getWirelessFrequency():​number`  ​
-  ​Get the currently set wireless redstone frequency.\\ +  ​获取当前设定的无线红石频率。 ​  
-  //Added in OC 1.3. Only available on tier two redstone cards.//+**自OC 1.3起添加:**仅可用于2级红石卡。\\ 
 +\\
 - `setWirelessFrequency(frequency:​number):​number`  ​ - `setWirelessFrequency(frequency:​number):​number`  ​
-  ​Set the wireless redstone frequency to use.\\ +  ​设定要使用的无线红石频率。 ​  
-  //Added in OC 1.3. Only available on tier two redstone cards.//+**自OC 1.3起添加:**仅可用于2级红石卡。\\ 
 +\\
 - `getWakeThreshold():​number`  ​ - `getWakeThreshold():​number`  ​
-  ​Gets the current wake-up threshold.+  ​获取当前唤醒阈值。 ​  
 +\\
 - `setWakeThreshold(threshold:​number):​number`  ​ - `setWakeThreshold(threshold:​number):​number`  ​
-  ​Sets the wake-up threshold to the specified number.+  ​将唤醒阈值设定为给定数字。\\
  
-Note that for mods such as ProjectRed, low values (such as the vanilla maximum of 15) may not function as expected for simple on/off values (opening a door for example), because they have a larger value range. You may need to use a higher value, such as 255.+请注意对于如ProjectRed(红石计划)这样的模组而言,较低的强度值(例如原版最高为15的强度值)可能不会像预期一样起到简单开/关信号的作用(例如用于开门)。因为这些模组的红石信号值范围更大。你可能需要指定一个更大的值,例如255。\\
  
-Example use:+使用例:
 ```lua ```lua
 local component = require("​component"​) local component = require("​component"​)
 local sides = require("​sides"​) local sides = require("​sides"​)
 local colors = require("​colors"​) local colors = require("​colors"​)
-local rs = component.redstone -- get primary redstone component+local rs = component.redstone --获取首选红石组件
 print(rs.getInput(sides.back)) print(rs.getInput(sides.back))
 rs.setBundledOutput(sides.bottom,​ colors.green,​ rs.getBundledInput(sides.top,​ colors.red)) rs.setBundledOutput(sides.bottom,​ colors.green,​ rs.getBundledInput(sides.top,​ colors.red))
-``+```
 ` `
 目录 目录
 ---- ----
 {{page>​component:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}} {{page>​component:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}}