31 lines
994 B
Lua
31 lines
994 B
Lua
|
|
-- probe.lua -- list every peripheral this computer can see, with its methods.
|
||
|
|
-- Drop a computer next to a block (or wire it up) and run `probe`. UI text in English.
|
||
|
|
|
||
|
|
local function dump(name)
|
||
|
|
print(name .. " -> type: " .. tostring(peripheral.getType(name)))
|
||
|
|
local methods = peripheral.getMethods(name)
|
||
|
|
if methods and #methods > 0 then
|
||
|
|
table.sort(methods)
|
||
|
|
for _, m in ipairs(methods) do print(" ." .. m) end
|
||
|
|
else
|
||
|
|
print(" (no methods)")
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
print("=== DIRECT SIDES ===")
|
||
|
|
local any = false
|
||
|
|
for _, side in ipairs({ "top", "bottom", "left", "right", "front", "back" }) do
|
||
|
|
if peripheral.isPresent(side) then any = true; dump(side) else print(side .. " -> (nothing)") end
|
||
|
|
end
|
||
|
|
|
||
|
|
print("")
|
||
|
|
print("=== ALL NAMES (incl. wired modem network) ===")
|
||
|
|
local names = peripheral.getNames()
|
||
|
|
if #names == 0 then print("(none)") end
|
||
|
|
for _, n in ipairs(names) do dump(n) end
|
||
|
|
|
||
|
|
if not any and #names == 0 then
|
||
|
|
print("")
|
||
|
|
print(">>> Nothing exposes a peripheral here.")
|
||
|
|
end
|