Advertisement
Xelostar

Pine3D installer

Dec 11th, 2022 (edited)
1,602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 KB | Software | 0 0
  1. local width, height = term.getSize()
  2.  
  3. local function update(text)
  4.     term.setBackgroundColor(colors.black)
  5.     term.setTextColor(colors.white)
  6.     term.setCursorPos(1, 9)
  7.     term.clearLine()
  8.     term.setCursorPos(math.floor(width/2 - string.len(text)/2), 9)
  9.     write(text)
  10. end
  11.  
  12. local function bar(ratio)
  13.     term.setBackgroundColor(colors.gray)
  14.     term.setTextColor(colors.lime)
  15.     term.setCursorPos(1, 11)
  16.  
  17.     for i = 1, width do
  18.         if (i/width < ratio) then
  19.             write("]")
  20.         else
  21.             write(" ")
  22.         end
  23.     end
  24. end
  25.  
  26. local function download(downloadPath, savePath)
  27.     term.setBackgroundColor(colors.black)
  28.     term.setTextColor(colors.white)
  29.     term.setCursorPos(1, 13)
  30.     term.clearLine()
  31.     term.setCursorPos(1, 14)
  32.     term.clearLine()
  33.     term.setCursorPos(1, 15)
  34.     term.clearLine()
  35.     term.setCursorPos(1, 16)
  36.     term.clearLine()
  37.     term.setCursorPos(1, 17)
  38.     term.clearLine()
  39.     term.setCursorPos(1, 13)
  40.  
  41.     print("Accessing https://raw.githubusercontent.com/Xella37/Pine3D/master/"..downloadPath)
  42.     local rawData = http.get("https://raw.githubusercontent.com/Xella37/Pine3D/master/"..downloadPath)
  43.     local data = rawData.readAll()
  44.     local file = fs.open(savePath, "w")
  45.     file.write(data)
  46.     file.close()
  47. end
  48.  
  49. function install()
  50.     term.setBackgroundColor(colors.black)
  51.     term.setTextColor(colors.yellow)
  52.     term.clear()
  53.  
  54.     local str = "Pine3D Installer"
  55.     term.setCursorPos(math.floor(width/2 - #str / 2), 2)
  56.     write(str)
  57.  
  58.     update("Installing...")
  59.     bar(0)
  60.  
  61.     update("Downloading Pine3D.lua...")
  62.     download("Pine3D.lua", "Pine3D.lua")
  63.     bar(0.2)
  64.  
  65.     update("Downloading betterblittle.lua...")
  66.     download("betterblittle.lua", "betterblittle.lua")
  67.     bar(0.4)
  68.  
  69.     update("Downloading Mountains.lua...")
  70.     download("Mountains.lua", "Mountains.lua")
  71.     bar(0.5)
  72.  
  73.     update("Downloading noise.lua...")
  74.     download("noise.lua", "noise.lua")
  75.     bar(0.6)
  76.  
  77.     update("Creating models folder...")
  78.     fs.makeDir("models")
  79.     bar(0.7)
  80.  
  81.     update("Downloading box model...")
  82.     download("models/box", "models/box")
  83.     bar(0.8)
  84.  
  85.     update("Downloading emerald model...")
  86.     download("models/emerald", "models/emerald")
  87.     bar(0.9)
  88.  
  89.     update("Downloading pineapple model...")
  90.     download("models/pineapple", "models/pineapple")
  91.     bar(1)
  92.  
  93.     update("Installation finished!")
  94.  
  95.     sleep(1)
  96.  
  97.     term.setBackgroundColor(colors.black)
  98.     term.setTextColor(colors.white)
  99.     term.clear()
  100.  
  101.     term.setCursorPos(1, 1)
  102.     write("Finished installation!\nPress any key to close...")
  103.  
  104.     os.pullEventRaw()
  105.  
  106.     term.clear()
  107.     term.setCursorPos(1, 1)
  108. end
  109.  
  110. install()
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement