diff --git a/listDevicesByType.lua b/listDevicesByType.lua new file mode 100644 index 0000000..f4bee6d --- /dev/null +++ b/listDevicesByType.lua @@ -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 \ No newline at end of file