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
api:colors:zh [2022/08/11 10:24]
fight_xing [Contents]
api:colors:zh [2023/11/29 05:57] (current)
hfsr [Colors(颜色) API]
Line 1: Line 1:
-Colors API+Colors(颜色) ​API
 ========= =========
 +此“API”提供了一个全局列表,让你能够以名称调用颜色,而无需以对应编号调用。此表可以双向查询。例如,`colors.blue`的值为`11`,而`colors[11]`的值为字符串`blue`。  ​
 +下表为所定义的颜色:
  
-**本篇文章的部分/​全部内容还没有进行翻译。**+- 白色 (`white`),编号:0 
 +- 橙色 (`orange`),编号:1 
 +- 品红色 (`magenta`),编号:2 
 +- 淡蓝色 (`lightblue`),编号:3 
 +- 黄色 (`yellow`),编号:4 
 +- 黄绿色 (`lime`),编号:5 
 +- 粉红色 (`pink`),编号:6 
 +- 灰色 (`gray`),编号:7 
 +- 淡灰色 (`silver`),编号:8 
 +- 青色 (`cyan`),编号:9 
 +- 紫色 (`purple`),编号:10 
 +- 蓝色 (`blue`),编号:11 
 +- 棕色 (`brown`),编号:12 
 +- 绿色 (`green`),编号:13 
 +- 红色 (`red`),编号:14 
 +- 黑色 (`black`),编号:15
  
-This "​API"​ serves a global table that allows you to refer to colors by their name, instead of their associated ID/number. The table serves as a look-up in both directions, so for example `colors.blue` has the value `11`, whereas `colors[11]` has the string value `blue`. These are the defined colors:+请注意编号从0而不是1开始。
  
-- White (`white`), Number: 0 +此表在你需要设置或读取集束红石线缆中信号的时候很有用,例如:
-- Orange (`orange`), Number: 1 +
-- Magenta (`magenta`),​ Number: 2 +
-- Light Blue (`lightblue`),​ Number: 3 +
-- Yellow (`yellow`), Number: 4 +
-- Lime (`lime`), Number: 5 +
-- Pink (`pink`), Number: 6 +
-- Gray (`gray`), Number: 7 +
-- Silver (`silver`), Number: 8 +
-- Cyan (`cyan`), Number: 9 +
-- Purple (`purple`), Number: 10 +
-- Blue (`blue`), Number: 11 +
-- Brown (`brown`), Number: 12 +
-- Green (`green`), Number: 13 +
-- Red (`red`), Number: 14 +
-- Black (`black`), Number: 15+
  
-Note that the indexing starts at zero, not one. 
- 
-Useful for setting or getting bundled redstone output or input, for example: 
 ```lua ```lua
 local component = require("​component"​) local component = require("​component"​)
Line 32: Line 31:
 rs.setBundledOutput(sides.back,​ colors.green,​ rs.getBundledInput(sides.front,​ colors.blue)) rs.setBundledOutput(sides.back,​ colors.green,​ rs.getBundledInput(sides.front,​ colors.blue))
 ``` ```
-would output the back signal strength to the front.+会将后方的信号强度输出到前方。
  
 目录 目录
 ----------- -----------
 {{page>​api:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}} {{page>​api:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}}