API/sides/zh
Sides(方向) API
此“API”提供了一份全局表,以便你通过名称来引用相对/绝对方向,而无需使用它们的编号。底层的编号值与Minecraft内部的编号(即名为ForgeDirection的Enum)完全一致。此表提供了双向查询,因此你既可以将名称解析为编号,也可以通过编号反查适合人类阅读的名称。例如,sides.top对应数字值1,而sides[1]的值为字符串top。每个方向都有数个别名,因此不太可能意外写错。以下是基本值:
- 底面 (
bottom), 数字: 0 - 顶面 (top), 数字: 1 - 背面 (back), 数字: 2 - 前面 (front), 数字: 3 - 右面 (right), 数字: 4 - 左面 (left), 数字: 5
默认情况下定义了如下别名:
- 底面:
down,negy- 顶面:up,posy- 背面:north,negz- 前面:south,posz,forward- 右面:west,negx- 左面:east,posx
方向在读写红石信号时很有用,例如:
local component = require("component") local sides = require("sides") local rs = component.redstone rs.setOutput(sides.back, rs.getInput(sides.left))目录
| < 100% 15% 15% > | ||
| API | OpenOS | buffer - colors - component - computer - event - filesystem - uuid - internet - keyboard - note - process - rc - robot - serialization - shell - sides - term - text - thread - transforms - unicode |
| ::: | Lua 库 | coroutine - package - io - os |