-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.lua
More file actions
30 lines (25 loc) · 803 Bytes
/
doc.lua
File metadata and controls
30 lines (25 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local component = require("component")
local fs = require("filesystem")
local alldevice = component.list()
local adress = {}
local i = 1
for k, v in pairs(alldevice) do
print(i .. " - " .. v)
i = i + 1
table.insert(adress, k)
end
local device = tonumber(io.read())
local diviceName = alldevice[adress[device]]
local function save(text, path)
local file, error = fs.open(path, "w")
file:write(text)
file:close()
end
local texts = "---@class " .. diviceName .. "\nlocal " .. diviceName .. " = {}\n\n"
local allMethods = {}
for k, v in pairs(component[diviceName]) do
print(diviceName .. "." .. k, v)
table.insert(allMethods, diviceName .. "." .. k .. " " .. tostring(v))
end
texts = texts .. table.concat(allMethods, "\n")
save(texts, "/home/" .. alldevice[adress[device]] .. ".lua")