Advertisement
NeOzay

getMethods

Aug 3rd, 2021 (edited)
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local component = require("component")
  2. local fs = require("filesystem")
  3. local textutils = require("serialization")
  4. local i=1
  5. local alldevice = component.list()
  6. local adress= {}
  7. for k,v in pairs(alldevice) do
  8.   print(i.." - "..v)
  9.   i = i+1
  10.   table.insert(adress,k)
  11. end
  12. local device = tonumber( io.read() )
  13.  
  14.  
  15. local function save(text, filename)
  16.   --[[if fs.exists(file) then
  17.     fs.remove(file)
  18.   end]]
  19.   local file,error = fs.open(filename,"w")
  20.   file:write(text)
  21.   file:close()
  22. end
  23.  
  24. local texts=""
  25. for k,v in pairs(component[alldevice[adress[device]]]) do
  26.   print(k,v)
  27.   if type(v)~="string" then
  28.     v = tostring(v)
  29.   end
  30.   texts=texts..k.."   "..v.."\n"
  31. end
  32.  
  33. save(texts,"/home/"..alldevice[adress[device]].."_methods")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement