Advertisement
Sanwiches

OpenC: list components and their methods

Jan 27th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. local component = require("component")
  2. local event = require("event")
  3.  
  4. local function findComps(type)
  5. local comps = {}
  6. local compNames = {}
  7.  
  8. for cAddress,cType in component.list(type) do
  9. -- Insert proxy methods table into comps table
  10. table.insert(comps, component.proxy(cAddress))
  11. -- Insert component type into compNames table
  12. table.insert(compNames, cType)
  13. end
  14. return comps, compNames
  15. end
  16.  
  17. local comps, compNames = findComps()
  18. for i=1, #comps do -- Iterate components
  19. print("\n"..compNames[i]..":")
  20. for k,v in pairs(comps[i]) do -- Iterate methods
  21. print(k) -- Print method name
  22. end
  23. print(" ")
  24. os.sleep(0.1)
  25. print("Press any key to continue")
  26. local _,_ = event.pull("key")
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement