Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this application acts as a App store
- local tArg = {...}
- local AllowedApps = {}
- local OwnedState = {}
- local w, h = term.getSize()
- settings.load(".settings")
- local TopApps = {}
- local function Clear()
- term.setBackgroundColor(colors.orange)
- term.clear()
- term.setCursorPos(1,1)
- end
- local function SetAppList()
- AllowedApps = tArg[2]
- TopApps = tArg[3]
- end
- local function GetAppList()
- shell.run("pastebin","run","DbZGEdRt")
- end
- function CUI(m,x,y) --declare function
- n=1
- local l = #m
- while true do
- term.setCursorPos(x,y)
- for i = 1, #m do
- if i==n then term.clearLine() print("<"..m[i]..">") else term.clearLine() print(m[i]) end
- local Cor = {term.getCursorPos()}
- term.setCursorPos(x,Cor[2])
- end
- local a, b = os.pullEvent("key")
- if b==keys.w and n>1 then n=n - 1 end
- if b==keys.s and n<l then n=n+1 end
- if b==keys.enter then break end
- end
- return n --return the value
- end
- function PageLoader_Touch(Name)
- local I
- for i = 1, #AllowedApps do
- if AllowedApps[i][1] == Name then I = i end
- end
- Clear()
- local AppName = Name
- local Author = AllowedApps[I][2]
- local Description = AllowedApps[I][4]
- local Code = AllowedApps[I][6]
- print("[X]")
- print(AppName)
- print(Author)
- print("==Download==")
- print(Description)
- local event
- local Result = "n"
- while true do
- event = {os.pullEvent()}
- if event[1] == "key" and event[2] == keys.x then Result = "exit" end
- if event[1] == "mouse_click" and event[3] < 3 and event[4] < 1 then Result = "exit" end
- if event[1] == "mouse_click" and event[3] < 11 and event[4] == 4 then Result = "Download" end
- if Result == "exit" or Result == "Download" then break end
- end
- if Results == "exit" then
- AppMenu_1()
- elseif Results == "Download" then
- shell.run("pastebin","run",Code)
- PageLoader_Touch(Name)
- end
- end
- function PageLoader_Key(Name)
- local I
- for i = 1, #AllowedApps do
- if AllowedApps[i][1] == Name then I = i end
- end
- Clear()
- local AppName = Name
- local Author = AllowedApps[I][2]
- local Description = AllowedApps[I][4]
- local Cost = AllowedApps[I][5]
- local Code = AllowedApps[I][6]
- print("===============")
- print(AppName)
- print(Author)
- print(Description)
- local options = {"Buy","exit"}
- if Cost == 0 then
- options[1] = "Download"
- else
- options[1] = "Buy | "..Cost.."C |"
- local n = CUI(options,3,7)
- if n == 1 then
- if AllowedApps[i][7] == true then
- shell.run("pastebin","run",Code)
- else
- shell.run("os/os_Programs/Scripts/ProvidedInstaller",AllowedPrograms[i][7][1],AllowedPrograms[i][6],AllowedPrograms[i][7][2])
- PageLoader_Key(Name)
- elseif n == 2 then
- AppMenu_2()
- end
- end
- function AppMenu_1()
- Clear()
- print("[X] App Store")
- print("[search bar]")
- local options = TopApps
- options[#options + 1] = "exit"
- local n = CUI(options,3,3)
- if n == 0 then
- shell.run(settings.get("os_DesktopLoc"))
- else
- PageLoader_Touch(TopApps[n])
- end
- end
- function AppMenu_2()
- Clear()
- term.setBackgroundColor(colors.lightGray)
- term.clearLine()
- term.setCursorPos(1,2)
- term.clearLine()
- term.setCursorPos(1,1)
- print("App Store")
- print("[search bar]")
- paintutils.drawFilledBox(1,h - 3, w, h, colors.lightGray)
- term.setBackgroundColor(colors.orange)
- local options = TopApps
- options[#options + 1] = "exit"
- local n = CUI(options,7,4)
- if options[n] == "exit" then
- shell.run(settings.get("os_DesktopLoc"))
- else
- PageLoader_Key(TopApps[n])
- end
- end
- if tArg[1] == "Ready" then
- SetAppList()
- else
- GetAppList()
- end
- if settings.get("os_TouchScreen") == true then
- AppMenu_1()
- else
- AppMenu_2()
- end
Add Comment
Please, Sign In to add comment