Upload files to "/"
This commit is contained in:
25
listDevicesByType.lua
Normal file
25
listDevicesByType.lua
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
-- List all peripherals grouped by type
|
||||||
|
local peripherals = peripheral.getNames()
|
||||||
|
local grouped = {}
|
||||||
|
|
||||||
|
-- Group peripherals by type
|
||||||
|
for _, name in ipairs(peripherals) do
|
||||||
|
local pType = peripheral.getType(name)
|
||||||
|
if not grouped[pType] then
|
||||||
|
grouped[pType] = {}
|
||||||
|
end
|
||||||
|
table.insert(grouped[pType], name)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Display grouped results
|
||||||
|
print("=== Network Devices ===")
|
||||||
|
print("Total devices found: " .. #peripherals)
|
||||||
|
print("")
|
||||||
|
|
||||||
|
for pType, devices in pairs(grouped) do
|
||||||
|
print(string.format("[%s] (%d found)", pType, #devices))
|
||||||
|
for _, name in ipairs(devices) do
|
||||||
|
print(" - " .. name)
|
||||||
|
end
|
||||||
|
print("")
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user