Advertisement
Guest User

Computercraft Peripheral debugger 1.0

a guest
Sep 1st, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | None | 0 0
  1. local tArgs = {...}
  2.  
  3. local side
  4. if #tArgs >= 1 then
  5.     -- use arg value
  6.     side = tArgs[1]
  7. else
  8.     print("usage: peripheralinfo <side>")
  9.     return
  10. end
  11.  
  12. if not peripheral.isPresent(side) then
  13.     print("No peripheral found")
  14.     return
  15. end
  16.  
  17. local ptype = peripheral.getType(side)
  18. local methods = peripheral.getMethods(side)
  19.  
  20. print("Type: ", ptype)
  21. print("Methods:")
  22.  
  23. local nLinesPrinted = 2
  24. local w,h = term.getSize()
  25.  
  26. for _, m in ipairs(methods) do
  27.     if nLinesPrinted >= h - 2 then
  28.         term.write("Press any key to continue")
  29.         os.pullEvent("key")
  30.         term.clearLine()
  31.         term.setCursorPos(1, h)
  32.     end
  33.     nLinesPrinted = nLinesPrinted + print(" ",m)
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement