CC: Relative Routing
CC: Relative Routing 添加了两个 ComputerCraft 外设,让你能够使用相对坐标而非外设 ID 与世界交互,从而使你的程序具备可移植性和可复现性。
方块
Redstone Router(红石路由器)
向相对坐标和方块面发送无线红石信号。
将 CC 计算机连接到 Redstone Router,然后使用 redstone_router 外设:
local router = peripheral.find("redstone_router")
-- 对路由器以东 3、向上 0、以北 2 的方块的北面施加红石信号
router.setRedstone(3, 0, -2, "north", 15)
-- 读取红石状态
print(router.getRedstone(3, 0, -2, "north")) -- 15
-- 清除所有活动信号
router.clearAll()
API
| 方法 | 描述 |
|---|---|
setRedstone(x, y, z, side, power) |
在目标方块的指定面上设置红石信号(强度 0–15)。强度为 0 时移除信号。 |
getRedstone(x, y, z, side) |
返回该偏移量 + 面当前存储的信号强度。 |
clearAll() |
移除此路由器上的所有活动信号。 |
side 可以是以下之一:north south east west up down
Peripheral Router(外设路由器)
使用相对坐标而非外设名称或连接侧面来包装附近任何兼容 CC 的外设。该外设可以像直接连接到计算机一样使用。
local router = peripheral.find("peripheral_router")
-- 包装位于偏移量 (3, 0, 0) 的显示器
local mon = router.wrap(3, 0, 0)
mon.setTextScale(1)
mon.clear()
mon.setCursorPos(1, 1)
mon.write("Hello from relative routing!")
-- 在包装前检查某个偏移量处是否存在外设
if router.isPresent(0, 2, 0) then
print(router.getType(0, 2, 0)) -- 例如 "monitor"
print(router.getMethods(0, 2, 0)) -- 列出所有方法
end
-- 无需包装即可调用单个方法
router.call(3, 0, 0, "write", "Hello")
-- 你甚至可以移动流体
local input_fluid_tank = router.wrap(1,0,0)
local output_fluid_tank = router.wrap(3,0,0)
local moved = output_fluid_tank.pullFluid(input_fluid_tank, 1000, "minecraft:water")
print(moved .. " mB moved")
API
| 方法 | 描述 |
|---|---|
wrap(x, y, z) |
返回一个包含目标外设所有方法的代理对象。建议在与外设交互时使用此方法。 |
isPresent(x, y, z) |
如果偏移量处存在外设,则返回 true。 |
getType(x, y, z) |
返回外设类型的字符串;如果不存在则返回 nil。 |
getMethods(x, y, z) |
返回外设上所有方法名的表格。 |
call(x, y, z, method, ...) |
调用指定的单个方法。注意:对于返回值的方法可能会返回 nil。如果需要返回值,请使用 wrap()。 |
坐标是相对于 Peripheral Router 方块本身的。适用于任何 CC:Tweaked 外设:显示器、扬声器、磁盘驱动器、调制解调器以及其他模组添加的外设。
Target Wand(目标法杖)
Target Wand 是一个辅助物品,用于打印相对于路由器的任意方块的正确相对坐标,这样你就不必手动计数方块了。
用法:
- 右键点击 Redstone Router 或 Peripheral Router 以将其选为控制器。
- 右键点击任何其他方块,聊天栏中将显示相对坐标和一个可直接使用的 Lua 代码片段。
对于 Peripheral Router 的目标,它还会检测该位置是否有外设(以及是什么类型的外设)。
配置
配置文件位于 config/ccrelativerouting-common.toml。
| 选项 | 默认值 | 描述 |
|---|---|---|
maxRange |
128 |
Redstone Router 偏移量的最大距离 |
peripheralMaxRange |
128 |
Peripheral Router 偏移量的最大距离 |
CC: Relative Routing
CC: Relative Routing adds two ComputerCraft peripherals that lets you interact with the world using relative coordinates instead of peripheral IDs, making your programs portable and reproducible.
Blocks
Redstone Router
Send wireless redstone signals to relative coordinates and block faces.
Connect a CC computer to the Redstone Router, then use the redstone_router peripheral:
local router = peripheral.find("redstone_router")
-- Power the north face of the block 3 east, 0 up, 2 north of the router
router.setRedstone(3, 0, -2, "north", 15)
-- Read redstone
print(router.getRedstone(3, 0, -2, "north")) -- 15
-- Remove all active signals
router.clearAll()
API
| Method | Description |
|---|---|
setRedstone(x, y, z, side, power) |
Sets a redstone signal (power 0–15) on the given face of the target block. Power 0 removes the signal. |
getRedstone(x, y, z, side) |
Returns the currently stored power for that offset + face. |
clearAll() |
Removes all active signals from this router. |
side is one of: north south east west up down
Peripheral Router
Wrap any CC-compatible peripheral nearby using relative coordinates instead of a peripheral name or side. The peripheral can be used as if it was connected to the computer.
local router = peripheral.find("peripheral_router")
-- Wrap a monitor at offset (3, 0, 0)
local mon = router.wrap(3, 0, 0)
mon.setTextScale(1)
mon.clear()
mon.setCursorPos(1, 1)
mon.write("Hello from relative routing!")
-- Check what's at an offset before wrapping
if router.isPresent(0, 2, 0) then
print(router.getType(0, 2, 0)) -- e.g. "monitor"
print(router.getMethods(0, 2, 0)) -- list all methods
end
-- Call a single method without wrapping
router.call(3, 0, 0, "write", "Hello")
-- You can even move fluids
local input_fluid_tank = router.wrap(1,0,0)
local output_fluid_tank = router.wrap(3,0,0)
local moved = output_fluid_tank.pullFluid(input_fluid_tank, 1000, "minecraft:water")
print(moved .. " mB moved")
API
| Method | Description |
|---|---|
wrap(x, y, z) |
Returns a proxy object with all the target peripheral's methods. Prefer this for interacting with peripherals. |
isPresent(x, y, z) |
Returns true if a peripheral exists at the offset. |
getType(x, y, z) |
Returns the peripheral type string, or nil if none. |
getMethods(x, y, z) |
Returns a table of all method names on the peripheral. |
call(x, y, z, method, ...) |
Calls a single named method. Note: may return nil for value-returning methods. Use wrap() when you need return values. |
Coordinates are relative to the Peripheral Router block itself. Works with any CC:Tweaked peripheral: monitors, speakers, disk drives, modems, and peripherals added by other mods.
Target Wand
The Target Wand is a helper item that prints the correct relative coordinates for any block relative to a router, so you never have to count blocks manually.
Usage:
- Right-click a Redstone Router or Peripheral Router to select it as the controller.
- Right-click any other block to print the relative coordinates and a ready-to-use Lua snippet in chat.
For Peripheral Router targets, it also detects what peripheral (if any) is at that position.
Configuration
The config file is at config/ccrelativerouting-common.toml.
| Option | Default | Description |
|---|---|---|
maxRange |
128 |
Maximum distance for Redstone Router offsets |
peripheralMaxRange |
128 |
Maximum distance for Peripheral Router offsets |
下载 CC: Relative Routing
下载 CC: Relative Routing
下载 CC: Relative Routing
下载 CC: Relative Routing
下载 CC: Relative Routing
下载 CC: Relative Routing
下载 CC: Relative Routing
下载 CC: Relative Routing
修复了在某些模组流体罐中流体移动不工作的问题
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
评论 0
登录后参与评分
还没有评论,来抢沙发吧