Improve Create peripheral detection and add diagnostics

This commit is contained in:
2026-07-16 21:00:29 +02:00
parent aac7e4f52d
commit d586491a07
3 changed files with 66 additions and 9 deletions
+43
View File
@@ -0,0 +1,43 @@
-- Writes all attached peripheral types, methods and Block Reader data to a file.
local outputName = "create_debug.txt"
local output = assert(fs.open(outputName, "w"))
local function writeLine(text)
text = tostring(text or "")
output.writeLine(text)
print(text)
end
local names = peripheral.getNames()
table.sort(names)
writeLine("CREATE PERIPHERAL DEBUG")
writeLine("Computer ID: " .. os.getComputerID())
writeLine("Peripherals: " .. #names)
writeLine("")
for _, name in ipairs(names) do
local types = { peripheral.getType(name) }
local methods = peripheral.getMethods(name) or {}
table.sort(methods)
writeLine(("[%s]"):format(name))
writeLine("Types: " .. table.concat(types, ", "))
writeLine("Methods: " .. table.concat(methods, ", "))
local hasBlockData = false
for _, method in ipairs(methods) do
if method == "getBlockData" then hasBlockData = true end
end
if hasBlockData then
local ok, data = pcall(peripheral.call, name, "getBlockData")
writeLine("getBlockData OK: " .. tostring(ok))
writeLine(ok and textutils.serialize(data) or tostring(data))
end
writeLine("")
end
output.close()
print("Fertig: " .. outputName)