Advertisement
drime

методы компонентов [OpenComputers]

May 27th, 2024
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | Source Code | 0 0
  1. local component = require("component")
  2. local term = require('term')
  3. local text = require("text")
  4. local components = {}
  5. local methods = {}
  6. local offset = 0
  7. local Text = {}
  8. local N = 0
  9.  
  10. term.clear()
  11. for address, name in component.list() do
  12.   if name:len() > offset then
  13.     offset = name:len()
  14.   end
  15.   components[address] = name
  16. end
  17.  
  18. offset = offset + 2
  19. print(' -------- Найденные компоненты --------')
  20. for address, name in pairs(components) do
  21.   io.write('['..N..']'..text.padRight(name, offset) .. '\n')
  22.   Text[N] = name
  23.   N = N + 1
  24. end
  25. print(' --------------------------------------')
  26. io.write('Введите N компонента >> ')
  27. local name = io.read()
  28. if component.isAvailable(Text[tonumber(name)]) then
  29.   t = component.getPrimary(Text[tonumber(name)])
  30.   for k,v in pairs(t) do
  31.     table.insert(methods,'>> Метод: '..k..'\nДокументация: '..tostring(v))
  32.   end
  33.   term.clear()
  34.   print('Нажимайте ENTER для продолжения'..'\n')
  35.   for k,v in pairs(methods) do
  36.     print('['..k..'] '..v)
  37.     io.read()
  38.   end
  39. else
  40.   print('Ошибка. Компонента '..name..' не существует!')
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement