Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local backColor = colors.white
- local Name = ""
- local UID = ""
- function ManualInstall()
- local loop = true
- local e,b,x,y
- local click = false
- local ErrMsg = ""
- local Msg = ""
- while(loop) do
- parallel.waitForAny(
- --GUI
- function()
- term.setBackgroundColor(backColor)
- term.clear()
- --Title
- paintutils.drawPixel(4,2, backColor)
- term.setCursorPos(4,2)
- term.setTextColor(colors.black)
- term.write("-Code Download-")
- --Return Button
- paintutils.drawPixel(2,2, colors.red)
- term.setCursorPos(2,2)
- term.setTextColor(colors.white)
- term.write("<")
- --UID TextBox
- paintutils.drawPixel(2,4, backColor)
- term.setCursorPos(2,4)
- term.setTextColor(colors.black)
- term.write("UID")
- paintutils.drawLine(2,5,11,5,colors.black)
- term.setCursorPos(2,5)
- term.setTextColor(colors.white)
- term.write(UID)
- --Name TextBox
- paintutils.drawPixel(2,7, backColor)
- term.setCursorPos(2,7)
- term.setTextColor(colors.black)
- term.write("Name")
- paintutils.drawLine(2,8,11,8,colors.black)
- term.setCursorPos(2,8)
- term.setTextColor(colors.white)
- term.write(Name)
- --Download Button
- paintutils.drawPixel(2,10, colors.green)
- term.setCursorPos(2,10)
- term.setTextColor(colors.black)
- term.write("Download")
- --Messages
- if (ErrMsg ~= "") then
- paintutils.drawPixel(2,12, backColor)
- term.setCursorPos(2,12)
- term.setTextColor(colors.red)
- term.write(ErrMsg)
- elseif (Msg ~= "") then
- paintutils.drawPixel(2,12, backColor)
- term.setCursorPos(2,12)
- term.setTextColor(colors.green)
- term.write(Msg)
- end
- sleep(2)
- end,
- function()
- e,b,x,y = os.pullEvent("mouse_click")
- click = true
- end
- )
- if (click==true) then
- if (x==2 and y==2) then
- loop = false
- elseif (y==5 and x>=2 and x<=11) then
- paintutils.drawPixel(2,5, colors.black)
- term.setCursorPos(2,5)
- term.setTextColor(colors.white)
- UID = read()
- elseif (y==8 and x>=2 and x<=11) then
- paintutils.drawPixel(2,8, colors.black)
- term.setCursorPos(2,8)
- term.setTextColor(colors.white)
- Name = read()
- elseif (y==10 and x>=2 and x<=9) then
- if (Name == "" or UID == "") then
- Msg = ""
- ErrMsg = "Missing info!"
- elseif (fs.exists("Apps/" .. Name)) then
- Msg = ""
- ErrMsg = "Name already in use!"
- else
- term.setTextColor(colors.white)
- shell.run("pastebin", "get", UID, "Apps/" .. Name .. "/" .. Name .. ".lua")
- local fUID = fs.open("Apps/" .. Name .. "/UID.txt", "w")
- fUID.write(UID)
- fUID.close()
- Msg = "Download successful!"
- ErrMsg = ""
- end
- end
- click = false
- end
- end
- end
- function DeleteApp()
- local lsApps = {}
- local loop = true
- while(loop) do
- --GUI
- term.setBackgroundColor(backColor)
- term.clear()
- --Title
- paintutils.drawPixel(4,2, backColor)
- term.setCursorPos(4,2)
- term.setTextColor(colors.black)
- term.write("-Delete Apps-")
- --Return Button
- paintutils.drawPixel(2,2, colors.red)
- term.setCursorPos(2,2)
- term.setTextColor(colors.white)
- term.write("<")
- local i = 4
- for _, file in ipairs(fs.list("Apps")) do
- if (file~="Market" and file~="Options") then
- paintutils.drawPixel(2,i, colors.red)
- term.setCursorPos(2,i)
- term.setTextColor(colors.white)
- term.write(file)
- lsApps[i]=file
- i=i+2
- end
- end
- --Click Buttons
- local e,b,x,y = os.pullEvent("mouse_click")
- if (x==2 and y==2) then
- loop = false
- else
- local xLen = string.len(lsApps[y])
- if (x>=2 and x<=xLen+1) then
- fs.delete("Apps/" .. lsApps[y])
- end
- end
- end
- end
- function UpdateApp()
- local lsApps = {}
- local loop = true
- while(loop) do
- --GUI
- term.setBackgroundColor(backColor)
- term.clear()
- --Title
- paintutils.drawPixel(4,2, backColor)
- term.setCursorPos(4,2)
- term.setTextColor(colors.black)
- term.write("-Delete Apps-")
- --Return Button
- paintutils.drawPixel(2,2, colors.red)
- term.setCursorPos(2,2)
- term.setTextColor(colors.white)
- term.write("<")
- local i = 4
- for _, file in ipairs(fs.list("Apps")) do
- paintutils.drawPixel(2,i, colors.yellow)
- term.setCursorPos(2,i)
- term.setTextColor(colors.white)
- term.write(file)
- lsApps[i]=file
- i=i+2
- end
- --Click Buttons
- local e,b,x,y = os.pullEvent("mouse_click")
- if (x==2 and y==2) then
- loop = false
- else
- local xLen = string.len(lsApps[y])
- if (x>=2 and x<=xLen+1) then
- fs.delete("Apps/" .. lsApps[y] .. "/" .. lsApps[y] .. ".lua")
- local fUID = fs.open("Apps/" .. lsApps[y] .. "/UID.txt", "r")
- shell.run("pastebin", "get",fUID.readLine() , "Apps/" .. lsApps[y] .. "/" .. lsApps[y] .. ".lua")
- end
- end
- end
- end
- function BrowseApps()
- end
- function EventsMain(x,y)
- if (x==2 and y==2) then --Exit
- error("",0)
- elseif (x>=2 and x<=10 and y==4) then --Manual
- ManualInstall()
- elseif (x>=2 and x<=8 and y==6) then --Browse
- BrowseApps()
- elseif (x>=2 and x<=12 and y==8) then --Delete
- DeleteApp()
- elseif (x>=2 and x<=12 and y==10) then --Update
- UpdateApp()
- elseif (x>2 and x<=10 and y==18) then --Update OS
- fs.delete("startup.lua")
- shell.run("pastebin", "get", "Yir91aUq", "startup.lua")
- os.reboot()
- end
- end
- function GuiMain()
- term.setBackgroundColor(backColor)
- term.clear()
- --Title
- term.setTextColor(colors.black)
- term.setCursorPos(6,2)
- term.write("-App Market-")
- --Exit Button
- term.setTextColor(colors.white)
- paintutils.drawPixel(2,2,colors.red)
- term.setCursorPos(2,2)
- term.write("x")
- --Manual Button
- term.setTextColor(colors.white)
- paintutils.drawLine(2, 4, 9, 4, colors.yellow)
- term.setCursorPos(2,4)
- term.write("Use code")
- --Browse Button
- term.setTextColor(colors.white)
- paintutils.drawLine(2, 6, 7, 6, colors.yellow)
- term.setCursorPos(2,6)
- term.write("Browse")
- --Delete Button
- term.setTextColor(colors.white)
- paintutils.drawLine(2, 8, 12, 8, colors.red)
- term.setCursorPos(2,8)
- term.write("Delete Apps")
- --Delete Button
- term.setTextColor(colors.white)
- paintutils.drawLine(2, 10, 12, 10, colors.yellow)
- term.setCursorPos(2,10)
- term.write("Update Apps")
- --Delete Button
- term.setTextColor(colors.white)
- paintutils.drawLine(2, 18, 10, 18, colors.orange)
- term.setCursorPos(2,18)
- term.write("Update OS")
- end
- -- Main --
- local click = false
- while(true) do
- local e,b,x,y
- parallel.waitForAny(
- function()
- GuiMain()
- sleep(2)
- end,
- function()
- e,b,x,y = os.pullEvent("mouse_click")
- click = true
- end)
- if (click) then
- click = false
- EventsMain(x,y)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment