mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
feat(chest_sorter): 改进箱子分类器程序并添加比较器检测功能
添加比较器检测逻辑,优化物品分类流程,并增强错误处理和用户指导: 1. 使用比较器信号检测输入箱物品变化 2. 改进外围设备检测和分类逻辑 3. 添加详细的错误信息和教程内容 4. 新增测试比较器程序 5. 更新安装程序版本号
This commit is contained in:
30
data/computercraft/lua/rom/programs/test_comparator.lua
Normal file
30
data/computercraft/lua/rom/programs/test_comparator.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
-- Simple comparator test program
|
||||
local peripheral = require("peripheral")
|
||||
local term = require("term")
|
||||
local colors = require("colors")
|
||||
|
||||
print(colors.green .. "=== Comparator Test ===" .. colors.white)
|
||||
|
||||
-- 查找比较器
|
||||
local comparator = peripheral.find("comparator")
|
||||
if not comparator then
|
||||
print(colors.red .. "No comparator detected!" .. colors.white)
|
||||
|
||||
-- 列出所有连接的外围设备
|
||||
local peripherals = peripheral.getNames()
|
||||
if #peripherals > 0 then
|
||||
print(colors.yellow .. "Connected peripherals:" .. colors.white)
|
||||
for _, name in ipairs(peripherals) do
|
||||
local p_type = peripheral.getType(name)
|
||||
print("- " .. name .. " (Type: " .. p_type .. ")")
|
||||
end
|
||||
else
|
||||
print(colors.red .. "No peripherals detected at all." .. colors.white)
|
||||
end
|
||||
else
|
||||
print(colors.green .. "Comparator detected!" .. colors.white)
|
||||
print("Comparator type: " .. peripheral.getType(peripheral.find("comparator")))
|
||||
print("Output signal level: " .. comparator.getOutputSignal())
|
||||
end
|
||||
|
||||
print(colors.blue .. "Test completed." .. colors.white)
|
||||
Reference in New Issue
Block a user