Advertisement
paramus

AppMarket

Jan 23rd, 2025 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | Gaming | 0 0
  1. local backColor = colors.white
  2.  
  3. function ManualInstall()
  4.     term.setBackgroundColor(colors.black)
  5.     term.clear()
  6.     term.setCursorPos(1,1)
  7.     write("UID: ")
  8.     local UID = read()
  9.     write("Name: ")
  10.     local Name = read()
  11.  
  12.     if (fs.exists("Apps/" .. Name)) then
  13.         print("An App with the same name allready exists.")
  14.     else
  15.         shell.run("pastebin", "get", UID, "Apps/" .. Name .. "/" .. Name .. ".lua")
  16.         print("The App was downloaded successfully!")
  17.     end
  18. end
  19.  
  20. function DeleteApp()
  21.     term.setBackgroundColor(colors.black)
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24.     for _, file in ipairs(fs.list("Apps")) do
  25.       print(file)
  26.     end
  27.     write("> ")
  28.     local App = read()
  29.     fs.delete("Apps/" .. App)
  30. end
  31.  
  32. function BrowseApps()
  33.    
  34. end
  35.  
  36. function EventsMain(x,y)
  37.     if (x==2 and y==2) then --Exit
  38.         error("",0)
  39.     elseif (x>=2 and x<=10 and y==4) then --Manual
  40.         ManualInstall()
  41.     elseif (x>=2 and x<=8 and y==6) then --Browse
  42.         BrowseApps()
  43.     elseif (x>=2 and x<=12 and y==8) then --Delete
  44.         DeleteApp()
  45.     end
  46. end
  47.  
  48. function GuiMain()
  49.     term.setBackgroundColor(backColor)
  50.     term.clear()
  51.    
  52.     --Title
  53.     term.setTextColor(colors.black)
  54.     term.setCursorPos(6,2)
  55.     term.write("-App Market-")
  56.    
  57.     --Exit Button
  58.     term.setTextColor(colors.white)
  59.     paintutils.drawPixel(2,2,colors.red)
  60.     term.setCursorPos(2,2)
  61.     term.write("x")
  62.    
  63.     --Manual Button
  64.     term.setTextColor(colors.white)
  65.     paintutils.drawLine(2, 4, 9, 4, colors.yellow)
  66.     term.setCursorPos(2,4)
  67.     term.write("Use code")
  68.    
  69.     --Browse Button
  70.     term.setTextColor(colors.white)
  71.     paintutils.drawLine(2, 6, 7, 6, colors.yellow)
  72.     term.setCursorPos(2,6)
  73.     term.write("Browse")
  74.    
  75.     --Delete Button
  76.     term.setTextColor(colors.white)
  77.     paintutils.drawLine(2, 8, 12, 8, colors.red)
  78.     term.setCursorPos(2,8)
  79.     term.write("Delete Apps")
  80. end
  81.  
  82. -- Main --
  83. local click = false
  84. while(true) do
  85.     local e,b,x,y
  86.     parallel.waitForAny(
  87.     function()
  88.         GuiMain()
  89.         sleep(2)
  90.     end,
  91.     function()
  92.         e,b,x,y = os.pullEvent("mouse_click")
  93.         click = true
  94.     end)
  95.    
  96.     if (click) then
  97.         click = false
  98.         EventsMain(x,y)
  99.     end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement