创建:航空电子 — 适用于航空的ComputerCraft - 重制版

创建:航空电子 — 适用于航空的ComputerCraft - 重制版

Create: Avionics 的非官方 NeoForge 1.21.1 发行版,将 CC:Tweaked 计算机与 Create Aeronautics 载具连接起来。

技术

Create: Avionics

让你的飞艇实现自动驾驶。

为 Create: Aeronautics 中的每个可仪表化方块提供 CC: Tweaked 外设。读取姿态、高度、速度、航向。驱动油门、螺旋桨、气球气体。用 Lua 编写你的自动驾驶仪(这个宣传不太好,但确实如此!)

构建

  • 热气球的高度保持
  • 螺旋桨飞机的航向和俯仰自动驾驶仪
  • 绑定到方向盘的巡航控制
  • 用于固定马铃薯加农炮的跟踪炮塔
  • 任何你能为其编写控制回路的其他功能

开始

双引擎飞船上的航向保持:

local nav = peripheral.find("navigation_table")
local port, stbd = peripheral.find("analog_transmission")
local target = nav.getHeadingRad()

while true do local err = (target - nav.getHeadingRad() + math.pi) % (2*math.pi) - math.pi local diff = math.max(-5, math.min(5, err * 4)) port.setSignal(7 - diff); stbd.setSignal(7 + diff) sleep(0.05) end

三个外设,一个 P 控制器,飞船锁定航向。每个 Aeronautics(以及几乎所有 Create)方块都是外设——读取传感器、设置执行器、编写你需要的控制回路。

不仅仅是飞行器

相同的 peripheral.find() 接口驱动升降机、车辆和你的整个旋转网络——不仅仅是能飞的东西。

Create 电梯 —— 枚举楼层、呼叫轿厢、读取其位置:

local lift = peripheral.find("Create_ElevatorPulley")
lift.setTargetFloor(lift.getFloors()[3].y)   -- 将轿厢发送到第 3 层
repeat sleep(0.1) until lift.isArrived()
print("到达: " .. lift.getCurrentFloor().short_name)

动力学 SCADA —— 遍历旋转网络,超应力时报警:

local draw, capacity = 0, 0
for _, name in ipairs(peripheral.getNames()) do
    local p = peripheral.wrap(name)
    if p.getNetworkId then                       -- 任何动力学方块
        draw     = draw     + p.getStressImpact()
        capacity = capacity + p.getStressContribution()
        if p.isOverstressed() then
            print("超应力 " .. p.getSelfId() .. " (" .. p.getKind() .. ")")
        end
    end
end
print(("网络负载: %.0f / %.0f SU"):format(draw, capacity))

车辆 —— 轮座上的转向和制动覆盖:

for _, w in ipairs({ peripheral.find("wheel_mount") }) do
    w.setSteering(0.5)                                       -- -1..1 -> ±30 度
    if w.getTouchingFriction() < 0.5 then w.setBrake(0) end  -- 在湿滑地面上放松制动
end

getKind、getSubnetworkAnchorId、getColumnContacts、getTouchingFriction —— 读取端与写入端一样丰富。

完整 API 文档 —— 单位、机体坐标系约定、每个方法。

阅读并行指南。5 Hz 和 20 Hz 的感觉不同。

安装

需要: MC 1.21.1 · NeoForge 21.1.219+ · Create 6.0.10+ · Simulated/Aeronautics/Offroad 1.2.1+ · Sable 1.1.0+ · CC: Tweaked 1.115+

搭配使用

ccc · create-computercraft