_Jacques

componentTableCycler

Aug 28th, 2018
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local event = require("event")
  4.  
  5. local function cycleTable(x)
  6.     term.clear()
  7.     for k,v in pairs(component[x]) do
  8.         print(k,v)
  9.         event.pull("key_up")
  10.     end
  11. end
  12.  
  13. local function main()
  14.     io.write("What component table do you need to read through?\n")
  15.     local table = io.read()
  16.     os.sleep(0.5)
  17.     if type(component[table]) == "table" then
  18.         cycleTable(table)
  19.     else
  20.         print("Not a valid table!")
  21.         os.sleep(1)
  22.         term.clear()
  23.         main()
  24.     end
  25. end
  26.  
  27. term.clear()
  28. io.write("Component table cycler v.1\n")
  29. os.sleep(1)
  30. term.clear()
  31. main()
Advertisement
Add Comment
Please, Sign In to add comment