Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function APILoader(apiName, apiPastebin) -- Used across several programs - but we can't use it from an API, because then how would we load it?
- os.unloadAPI(apiName)
- if fs.exists(apiName)
- then
- os.loadAPI(apiName)
- else
- shell.run("pastebin","get",apiPastebin,apiName)
- os.loadAPI(apiName)
- end
- end
- APILoader("commonFunctions","x5Ve1KSK")
- function main()
- print("Welcome to the Open Peripherals Method Explorer")
- print("Version: RC1")
- print("Developed by CMaster")
- print("Distributed under the CC-BY-SA v4.0 license")
- print("Bring bug reports to the Open Peripheral Explorer thread on the ComputerCraft Forums")
- print("Press enter to begin")
- read()
- continue = true
- while continue do
- periphToView = peripheral.wrap(commonFunctions.selectPeripheral())
- term.clear()
- if periphToView == nil
- then
- print()
- print("Not an actual peripheral. Please Reselect.")
- print("Enter to continue...")
- read()
- else
- if periphToView["getAdvancedMethodsData"] == nil
- then
- print()
- print("Not an OpenPeripherals Peripheral")
- print("Enter to continue...")
- read()
- else
- pickMethod(periphToView)
- end
- end
- end
- end
- function toggle()
- cont = false
- end
- function pickMethod(periph)
- methods = periph.getAdvancedMethodsData()
- methodList = {}
- for k, v in pairs(methods) do
- table.insert(methodList,{["text"] = k, ["func"] = displayMethod, ["params"] = {v}})
- end
- cont = true
- table.insert(methodList,{["text"] = "Back to Peripheral Select", ["func"] = toggle })
- while cont do
- commonFunctions.menu(methodList,"Select method to view")
- end
- end
- function displayMethod(methodList)
- term.clear()
- term.setCursorPos(1,1)
- print("Method Overview for " .. methodList.name)
- print("Description: " .. methodList.description)
- rType = ""
- for k, v in pairs(methodList.returnTypes) do
- rType = rType .. v .. ", "
- end
- print("Returns as: " .. rType )
- print("Arguments:")
- for k,v in pairs(methodList.args) do
- if v.optional == "true" then
- opt = " (optional) "
- else
- opt = " "
- end
- print(v.type .. " " .. v.name .. opt .. ": " .. v.description)
- end
- print("Enter to return")
- read()
- end
- print(main())
Advertisement
Add Comment
Please, Sign In to add comment