NeOzay

makeDoc

Aug 3rd, 2021
691
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2. local fs = require("filesystem")
  3. local alldevice = component.list()
  4. local adress= {}
  5.  
  6. local i=1
  7.  
  8. for k,v in pairs(alldevice) do
  9.   print(i.." - "..v)
  10.   i = i+1
  11.   table.insert(adress,k)
  12. end
  13. local device = tonumber(io.read())
  14.  
  15.  
  16. local function save(text,path)
  17.   local file,error = fs.open(path,"w")
  18.   file:write(text)
  19.   file:close()
  20. end
  21.  
  22. local texts= "---@class "..alldevice[adress[device]].."\nlocal "..alldevice[adress[device]].." = {}\n\n"
  23. for k,v in pairs(component[alldevice[adress[device]]]) do
  24.   print(k,v)
  25.   if tostring(v) =="function" then
  26.     texts=texts.."function "..alldevice[adress[device]].."."..k.."() end".."\n\n"
  27.   else
  28.     texts = texts..alldevice[adress[device]].."."..k.." = \""..v.."\"\n\n"
  29.   end
  30.  
  31. end
  32.  
  33. save(texts,"/home/"..alldevice[adress[device]]..".lua")
RAW Paste Data