Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Appstore Browser
- --this program is the Browser for the APP Store
- --this program is for Minecraft 1.16.5, CC Tweaked
- local CurrentPastebinAppListCode = ""
- local AppStore_UseHTTP = false
- local AppNames = {}
- local AppHandler = {}
- local SearchTabState = false
- local Topic = ""
- local ShownApps = {}
- local ShownApps_Position = {}
- local ShownApps_File = {}
- local w,h = term.getSize()
- function CenterText(y,text)
- local x = math.floor((w - string.len(text)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(text)
- end
- function GetOnlineItems()
- local OnlineData_AppsList = nil
- if AppStore_UseHTTP == true then
- elseif AppStore_UseHTTP == false then
- shell.run("C_Pastebin","get",CurrentPastebinAppListCode,"Temp_StoreAppLinks")
- end
- local file = fs.open("Temp_StoreAppLinks","r")
- for i = 1, #file.list()/2 do
- AppName[i] = file.readLine(i*2)
- AppHandler[i] = file.readLine(i*2+1)
- end
- file.close()
- end
- function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function DrawBrowser()
- Clear()
- print("App Browser")
- if AppStore_UseHTTP == false then
- print("HTTP USE BEEN DISABLED, FOR NOW ALL APPS ARE SHOWN FROM DEDICATED PASTEBIN LIST")
- end
- local L = 4
- local Line = nil
- for i = 1, #ShownApps/3 do
- Line = {ShownApps[i],ShownApps[i+1],ShownApps[i+2]}
- term.setCursorPos(10,L)
- term.write(Line[1])
- term.setCursorPos(20,L)
- term.write(Line[2])
- term.setCursorPos(30,L)
- term.write(Line[3])
- L = L + 5
- end
- end
- function DrawImages()
- --not functional yet
- end
- function SearchApps()
- ShownApps = {}
- local X = 1
- local Y = 1
- for i = 1, #AppNames do
- if string.find(AppNames[i],Topic) == true then
- ShownApps[#ShownApps+1] = AppNames[i]
- ShownApps_Postion[#ShownApps] = X, Y
- ShownApps_File[#ShownApps] = AppFile[i]
- if X < 3 then
- X = X + 1
- else
- X = 1
- Y = Y + 1
- end
- end
- end
- DrawBrowser()
- BROWSER()
- end
- function findMouse(x,y)
- local X = 1
- local Y = 1
- local I = -1
- for i = 1, #ShownApps do
- if x < X*10 and y-5 < Y*5 then
- I = i
- else
- if X < 3 then
- X = X + 1
- else
- X = 1
- Y = Y + 1
- end
- end
- end
- if I == -1 then
- BROWSER()
- else
- fs.delete("Temp_StoreAppLinks")
- shell.run("ApertureDL_AppStore_AppPage",ShownApps_File[I],ShownApps_File[I])
- end
- end
- Clear()
- GetOnlineItems()
- DrawBrowser()
- function BROWSER()
- local input = read()
- while true do
- local event, Item, x, y = os.pullEvent()
- if event == "mouse_click" and x < 3 and y < 3 then
- shell.run("ApertureDL_AppStore")
- break
- elseif SearchBarState == true then
- if event == "key" and Item == keys.tab then
- SearchBarState = false
- elseif event == "key" and Item == keys.enter then
- Topic = input
- break
- elseif event == "key" then
- input = read()
- elseif event == mouse_click and Item == "left" and y > 5 then
- SearchBarState = false
- end
- elseif SearchBarState == false then
- if event == "key" and Item == keys.tab then
- SearchBarState = true
- elseif event == mouse_click and Item == "left" and y > 5 then
- if #ShownApps > 0 then
- findMouse(x, y)
- break
- end
- end
- end
- end
- SearchApps()
- end
- BROWSER()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement