Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --AppPage
- --this program shows the details of the Choosen App, and allows the User to either "Download", "Exit", or "Uninstall"
- --this program is for Minecraft 1.16.5, CC Tweaked
- local tArg = {..}
- local AppName = tArg[1]
- local AppDataCode = tArg[2]
- local AppAuthor = nil
- local AppDiscription = nil
- local AppLauncher = nil
- local ClientAppRelation = "Not Installed"
- local PageScroll = 1
- local AppDownloadCode = nil
- local y,h = term.getSize()
- term.clear()
- term.setcursorPos(1,1)
- print("APP PAGE")
- function CenterText(y,text)
- local x = math.floor((y - string.len(text)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(text)
- end
- function Download()
- fs.delete("Temp_AppData")
- shell.run(AppDownloadCode)
- local Apps = fs.open("AppList","a")
- local i = #AppList.list()
- AppList.setCursorPos(1,i+1)
- AppList.writeLine(AppName)
- AppList.writeLine(AppLauncher)
- AppList.close()
- shell.run(".ApertureOS_AppMenu")
- end
- function GetAppData()
- shell.run("pastebin","get",AppDataCode,"Temp_AppData")
- local file = fs.open("Temp_AppData","r")
- AppAuthor = file.readLine(3)
- AppDiscription = file.readLine(4)
- AppLauncher = file.readLine(5)
- AppDownloadCode = file.readLine(7)
- file.close()
- end
- function DrawMenu()
- term.setBackground(colors.white)
- paintutils.drawFilledBox(40,3,48,5,colors.green)
- term.setCursorPos(41,4)
- term.write("Download")
- CenterText(4,AppName)
- CenterText(6,AppAuthor)
- paintutils.drawFilledBox(1,1,3,3,colors.red)
- paintutils.drawLine(1,1,3,3,colors.black)
- paintutils.drawLine(1,3,3,1,colors.black)
- paintutils.drawFilledBox(2,8,49,30,colors.white)
- local Lines = require"cc.strings".wrap(AppDiscription, 45)
- for i = 1 #Lines do
- term.setCursorPos(3,i+9)
- term.write(Lines[i])
- end
- end
- GetAppData()
- DrawMenu()
- while true do
- local event, Item, x, y = os.pullEvent()
- if event == "mouse_click" and x > 40 and x < 48 and y > 3 and y < 5 and ClientAppRelation == "Not Installed" then --clicked on Download Button
- paintutils.drawFilledBox(10,4,40,8,colors.gray)
- CenterText(6,"DOWNLOADING APPLICATION, PLEASE WAIT")
- term.setCursorPos(10,7)
- textutils.slowWrite("==============================")
- sleep(20)
- Download()
- break
- elseif event == "mouse_click" and x < 3 and y < 3 then --returns back to Store Menu, not the browser
- shell.run(".ApertureOS_AppStore")
- break
- elseif event == "key" and Item == keys.down and PageScroll < 40 then
- PageScroll = PageScroll + 1
- term.scroll(1)
- elseif event == "key" and Item == keys.up and Page Scroll > 1 then
- PageScroll = PageScroll - 1
- term.scroll(-1)
- end
- DrawMenu()
- end
Add Comment
Please, Sign In to add comment