Advertisement
Jameelo

Lua Package Installer V2.0

May 17th, 2025 (edited)
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | Gaming | 0 0
  1. --[[
  2.     Package installer for the stuff I've made
  3.     It also has a progress bar!
  4. ]]
  5.  
  6. -------------------------Constant Declarations-------------------------
  7.  
  8. -- Common Utility Libraries
  9. local PACKAGES = {
  10.     -- APIs
  11.     ["common/systemLib.lua"] = "q4vfvQPk",
  12.     ["common/storageLib.lua"] = "SzD8A2sq",
  13.     ["common/mineLib.lua"] = "N0mkQCxV",
  14.     -- Startup
  15.     ["startup.lua"] = "tqVxm1HC",
  16.     -- Programs
  17.     ["stairMiner.lua"] = "QHf8evLE",
  18.     ["quarry.lua"] = "aaNTTxMV",
  19.     ["elevator.lua"] = "5F9wdhrm",
  20.     ["platformBuilder.lua"] = "F0HQRDnX",
  21.     ["lavaRefuel.lua"] = "yCMci8qT",
  22. }
  23.  
  24. -- Generic command line strings
  25. local INSTALLSHELL = "pastebin get %s %s"
  26. local UNINSTALLSHELL = "delete %s"
  27.  
  28. local maxProgress, progressBar = 0, 0
  29. for _ in pairs(PACKAGES) do maxProgress = maxProgress + 1 end
  30.  
  31. local function printProgressBar(current, max)
  32.     local progress = current/max -- Normalised progress
  33.     local width,_,_ = term.getSize()
  34.     local progressPips, n = width - 2, 0
  35.  
  36.     term.clear()
  37.     io.write("[")
  38.     while n < progressPips do
  39.         if (n/progressPips) > progress then
  40.             io.write(".")
  41.         else
  42.             io.write("|")
  43.         end
  44.         n = n + 1
  45.     end
  46.     io.write("]")
  47.     print("")
  48. end
  49.  
  50. -------------------------Start Program-------------------------
  51.  
  52. -- Install required libraries, ensure they are done first
  53. for k,v in pairs(PACKAGES) do
  54.     printProgressBar(progressBar, maxProgress)
  55.     print("Current package: ", k)
  56.     print(" ")
  57.     if fs.exists(k) == true then
  58.         shell.run(string.format(UNINSTALLSHELL,k))
  59.     end
  60.     shell.run(string.format(INSTALLSHELL,v,k))
  61.     progressBar = progressBar + 1
  62. end
  63.  
  64. printProgressBar(maxProgress,maxProgress)
  65. print("Installation complete\n:3")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement