Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local location = tostring(tArgs[1]) or nil
- local directory = "Peripherals"
- local sides = {["front"] = true, ["back"] = true, ["left"] = true, ["right"] = true, ["top"] = true, ["bottom"] = true}
- if location == nil or not sides[location] then
- error("Use: " .. shell.getRunningProgram() .. " <Valid side", 0)
- elseif not peripheral.isPresent(location) then
- error("Pheripheral isn't found, check side", 0)
- end
- local function source(command)
- return peripheral.call(location, command)
- end
- local function istable(elem)
- if (type(elem) == "table") then
- return true
- end
- end
- local type_p = peripheral.getType(location)
- local methods = peripheral.getMethods(location) or nil
- for k,v in pairs(methods) do
- if tostring(v) == "getAdvancedMethodsData" then
- methods_op = source("getAdvancedMethodsData")
- end
- end
- if methods == nil then
- print("Command <getmethods> failed")
- elseif methods_op == nil then
- print("Failed to obtain methods_op")
- end
- --if not fs.isDir(directory) then
- -- fs.makeDir(directory)
- --end
- if fs.exists(type_p) then
- fs.delete(type_p)
- end
- local output = io.open(type_p, 'w')
- output:write("Savage_Me55iah's Peripheral aid for")
- output:write("\n")
- output:write("Peripheral Type: " .. type_p)
- output:write("\n")
- output:write("\n")
- output:write("List of methods: ")
- if methods ~= nil then
- for k,v in pairs(methods) do
- output:write("\n")
- output:write(k .. ": " .. v)
- end
- end
- if methods_op ~= nil then
- output:write("\n")
- output:write("\n")
- output:write("Open Peripherals getAdvanceMethodsData >This was a pain to figure out!<")
- output:write("\n")
- for a,b in pairs(methods_op) do
- output:write("\n")
- if istable(b) then
- output:write(a .. "-")
- for c,d in pairs(b) do
- output:write("\n")
- if istable(d) then
- output:write(c .. "-")
- for e,f in pairs(d) do
- output:write("\n")
- if istable(d) then
- output:write(e .. "-")
- for g,h in pairs(d) do
- output:write("\n")
- if istable(h) then
- output:write(g .. "-")
- for i,j in pairs(h) do
- output:write("\n")
- i, j = tostring(i), tostring(j)
- output:write(i .. ": " .. j)
- end
- else
- output:write(g .. ": " .. h)
- end
- end
- else
- output:write(e .. ": " .. f)
- end
- end
- else
- output:write(c .. ": " .. d)
- end
- end
- else
- output:write(a .. ": " .. b)
- end
- output:write("\n")
- output:write("\n")
- output:write("-------------")
- output:write("\n")
- end
- end
- output:close()
- --else
- -- error("List already exists, to view type: edit " .. directory .. "/" .. type_p, 0)
- --end
- print("To view list anytime type: edit " .. type_p)
- print("Thank you for using Savage_Me55iah's Peripheral Aid")
- --print("Hit <y> to view any other key to exit")
- --e, char = os.pullEvent()
- --if char == "char y" then
- --shell.run("edit " .. type_p)
- --end
Advertisement
Add Comment
Please, Sign In to add comment