April_The_Sergal

peripheralScanner.lua

Jan 27th, 2026
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | Gaming | 0 0
  1. -- ============================================
  2. -- PERIPHERAL SCANNER
  3. -- ============================================
  4. -- Run this first to find peripheral names
  5. -- ============================================
  6.  
  7. print("=== PERIPHERAL SCANNER ===")
  8. print("")
  9.  
  10. local names = peripheral.getNames()
  11.  
  12. if #names == 0 then
  13.     print("No peripherals found!")
  14.     print("Make sure blocks are adjacent to the computer.")
  15. else
  16.     print("Found " .. #names .. " peripheral(s):")
  17.     print("")
  18.    
  19.     for _, name in ipairs(names) do
  20.         local pType = peripheral.getType(name)
  21.         local methods = peripheral.getMethods(name)
  22.        
  23.         print("Name: " .. name)
  24.         print("  Type: " .. pType)
  25.        
  26.         -- Check if it's an inventory
  27.         local isInventory = false
  28.         for _, method in ipairs(methods) do
  29.             if method == "list" or method == "getItemDetail" then
  30.                 isInventory = true
  31.                 break
  32.             end
  33.         end
  34.        
  35.         if isInventory then
  36.             print("  Has inventory: YES")
  37.             local inv = peripheral.wrap(name)
  38.             local size = inv.size and inv.size() or "?"
  39.             print("  Slots: " .. tostring(size))
  40.            
  41.             -- Count items
  42.             local items = inv.list()
  43.             local count = 0
  44.             for _ in pairs(items or {}) do
  45.                 count = count + 1
  46.             end
  47.             print("  Items: " .. count .. " stacks")
  48.         end
  49.        
  50.         print("")
  51.     end
  52. end
  53.  
  54. print("Copy the names you need into startup.lua CONFIG section")
Tags: lua
Add Comment
Please, Sign In to add comment