Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TermWidth, TermHeight = term.getSize()
- CurrentCursorY = 0
- FlipColourNext = false
- function flipColour()
- if (FlipColourNext) then
- term.setTextColor(colours.lightGrey)
- FlipColourNext = false
- else
- term.setTextColor(colours.grey)
- FlipColourNext = true
- end
- end
- function doesTextFit(text)
- local x, y = term.getCursorPos()
- local len = string.len(text)
- local endPos = x + len + 3
- if (endPos > TermWidth) then
- return false
- end
- return true
- end
- function printFormat(text)
- local x, y = term.getCursorPos()
- if (doesTextFit(text) == false) then
- term.setCursorPos(1, y + 1)
- end
- flipColour()
- term.write(text)
- end
- function printMethods(apiName)
- term.clear()
- term.setCursorPos(1, 1)
- print("API Name: " .. apiName)
- local methods = peripheral.getMethods(apiName)
- for i,v in ipairs(methods) do
- printFormat(v)
- term.setTextColour(colours.green)
- term.write(", ")
- end
- end
- function main()
- term.setCursorPos(1, 1)
- CurrentCursorY = 1
- term.clear()
- local periList = peripheral.getNames()
- for i = 1, #periList do
- print(periList[i] .. ": \"" .. peripheral.getType(periList[i]) .. "\"")
- end
- local w, h = term.getSize()
- term.setCursorPos(1, h - 3)
- print("Enter a side (or peripheral name) to list the methods of")
- term.setCursorPos(1, h)
- term.write("API> ")
- local apiName = read()
- if (peripheral.wrap(apiName) == nil) then
- term.clear()
- term.setCursorPos(1, 1)
- print("That API doesn't exist!")
- return
- end
- printMethods(apiName)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment