Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArg = {...}
- local scr_x,scr_y = term.getSize()
- local cprint = function(txt,y)
- local cX,cY = term.getCursorPos()
- term.setCursorPos(math.ceil(scr_x/2)-math.floor(#txt/2),y or cY)
- print(txt)
- end
- --[[
- if tArg[1] == "storelengthcheck" then
- return false, 0
- end
- if term.isColor() then
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- end
- term.clear()
- cprint("Sorry, but the Discover list is",3)
- cprint("down for maintainance.",4)
- cprint("Please check later.",6)
- sleep(0)
- os.pullEvent("char")
- if true then
- return false, 0
- end
- --]]
- if not std then std = {} end
- local getTableNum = function(tbl,str)
- for a = 1, #tbl do
- if tbl[a] == str then
- return a
- end
- end
- return false
- end
- local Headers = {["User-Agent"] = "DiscoverAPI",["User-Net"] = "DiscoverNetwork"}
- local url, query = "https://discoverapi.xyz/api/store", "cmd=list_categories"
- local req = http.post(url, query, Headers)
- if not req then
- return false
- end
- req = textutils.unserialize(req.readAll())
- std.storeCatagoryNames = req.data
- query = "cmd=list_apps"
- req = http.post(url, query, Headers)
- if not req then
- return false
- end
- req = textutils.unserialize(req.readAll()).data
- std.storeURLs = {}
- if tArg[1] == "storelengthcheck" then
- return true, #req
- end
- local buffer,r
- for a = 1, #req do
- r = req[a]
- buffer = {
- title = r.name,
- url = {r.id}, --gotta interpret that differently than string URLs
- creator = r.creator,
- description = r.description,
- catagory = getTableNum(std.storeCatagoryNames,r.category),
- forumPost = "N/A ",
- keywords = {tostring(r.id)},
- }
- std.storeURLs[r.id] = buffer
- end
- std.contextualGet = function(appid)
- local url = "https://discoverapi.xyz/api/store"
- local query = "cmd=download&appid="..tostring(appid)
- local Headers = {["User-Agent"] = "DiscoverAPI",["User-Net"] = "DiscoverNetwork"}
- local contents = http.post(url, query, Headers)
- return contents
- end
- return true
Add Comment
Please, Sign In to add comment