Advertisement
Xelostar

CC:Minecraft installer

Dec 14th, 2022 (edited)
2,253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.67 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(path)
  27.     update("Downloading " .. path .. "...")
  28.  
  29.     term.setBackgroundColor(colors.black)
  30.     term.setTextColor(colors.white)
  31.     term.setCursorPos(1, 13)
  32.     term.clearLine()
  33.     term.setCursorPos(1, 14)
  34.     term.clearLine()
  35.     term.setCursorPos(1, 15)
  36.     term.clearLine()
  37.     term.setCursorPos(1, 16)
  38.     term.clearLine()
  39.     term.setCursorPos(1, 17)
  40.     term.clearLine()
  41.     term.setCursorPos(1, 13)
  42.  
  43.     print("Accessing https://raw.githubusercontent.com/Xella37/CC-Minecraft/master/"..path)
  44.     local rawData = http.get("https://raw.githubusercontent.com/Xella37/CC-Minecraft/master/"..path)
  45.     local data = rawData.readAll()
  46.     local file = fs.open(path, "w")
  47.     file.write(data)
  48.     file.close()
  49. end
  50.  
  51. function install()
  52.     term.setBackgroundColor(colors.black)
  53.     term.setTextColor(colors.yellow)
  54.     term.clear()
  55.  
  56.     local str = "CC:Minecraft Installer"
  57.     term.setCursorPos(math.floor(width/2 - #str / 2), 2)
  58.     write(str)
  59.  
  60.     local total = 21
  61.  
  62.     update("Installing...")
  63.     bar(0)
  64.  
  65.     download("Minecraft.lua")
  66.     bar(1/total)
  67.     download("Pine3D-minified.lua")
  68.     bar(2/total)
  69.     download("betterblittle.lua")
  70.     bar(3/total)
  71.     download("blittle")
  72.     bar(4/total)
  73.     download("noise.lua")
  74.     bar(5/total)
  75.     download("hotbar.nfp")
  76.     bar(6/total)
  77.     download("hotbarb.nfp")
  78.     bar(7/total)
  79.     download("logo.nfp")
  80.     bar(8/total)
  81.     download("hotbarb.nfp")
  82.     bar(9/total)
  83.     download("worldGradient.nfp")
  84.     bar(10/total)
  85.     download("controls.txt")
  86.     bar(11/total)
  87.     download("README.md")
  88.     bar(12/total)
  89.     download("LICENSE")
  90.     bar(13/total)
  91.  
  92.     update("Creating models folder...")
  93.     fs.makeDir("models")
  94.     bar(14/total)
  95.  
  96.     download("models/dirt")
  97.     bar(15/total)
  98.     download("models/grass")
  99.     bar(16/total)
  100.     download("models/leaves")
  101.     bar(17/total)
  102.     download("models/sand")
  103.     bar(18/total)
  104.     download("models/stone")
  105.     bar(19/total)
  106.     download("models/water")
  107.     bar(20/total)
  108.     download("models/wood")
  109.     bar(21/total)
  110.  
  111.     update("Installation finished!")
  112.  
  113.     sleep(1)
  114.  
  115.     term.setBackgroundColor(colors.black)
  116.     term.setTextColor(colors.white)
  117.     term.clear()
  118.  
  119.     term.setCursorPos(1, 1)
  120.     write("Finished installation!\nPress any key to close...")
  121.  
  122.     os.pullEventRaw()
  123.  
  124.     term.clear()
  125.     term.setCursorPos(1, 1)
  126. end
  127.  
  128. install()
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement