Advertisement
Xelostar

New Doom Installer

Feb 22nd, 2018
8,590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.98 KB | None | 0 0
  1. local function update(text)
  2.     term.setBackgroundColor(colors.black)
  3.     term.setTextColor(colors.white)
  4.     term.setCursorPos(1, 9)
  5.     term.clearLine()
  6.     term.setCursorPos(math.floor(51/2 - string.len(text)/2), 9)
  7.     write(text)
  8. end
  9.  
  10. local function bar(ratio)
  11.     term.setBackgroundColor(colors.gray)
  12.     term.setTextColor(colors.lime)
  13.     term.setCursorPos(1, 11)
  14.    
  15.     for i = 1, 51 do
  16.         if (i/51 < ratio) then
  17.             write("]")
  18.         else
  19.             write(" ")
  20.         end
  21.     end
  22. end
  23.  
  24. local function download(downloadPath, savePath)
  25.     term.setBackgroundColor(colors.black)
  26.     term.setTextColor(colors.white)
  27.     term.setCursorPos(1, 13)
  28.     term.clearLine()
  29.     term.setCursorPos(1, 14)
  30.     term.clearLine()
  31.     term.setCursorPos(1, 15)
  32.     term.clearLine()
  33.     term.setCursorPos(1, 16)
  34.     term.clearLine()
  35.     term.setCursorPos(1, 17)
  36.     term.clearLine()
  37.     term.setCursorPos(1, 13)
  38.    
  39.     print("Accessing https://raw.githubusercontent.com/Xelostar/CCDoom/master/"..downloadPath)
  40.     local rawData = http.get("https://raw.githubusercontent.com/Xelostar/CCDoom/master/"..downloadPath)
  41.     local data = rawData.readAll()
  42.     local file = fs.open(savePath, "w")
  43.     file.write(data)
  44.     file.close()
  45. end
  46.  
  47. local function pastebinD(code, savePath)
  48.     term.setBackgroundColor(colors.black)
  49.     term.setTextColor(colors.white)
  50.     term.setCursorPos(1, 13)
  51.     term.clearLine()
  52.     term.setCursorPos(1, 14)
  53.     term.clearLine()
  54.     term.setCursorPos(1, 15)
  55.     term.clearLine()
  56.     term.setCursorPos(1, 16)
  57.     term.clearLine()
  58.     term.setCursorPos(1, 17)
  59.     term.clearLine()
  60.     term.setCursorPos(1, 13)
  61.     shell.run("pastebin get "..code.." "..savePath)
  62. end
  63.  
  64. term.setBackgroundColor(colors.black)
  65. term.setTextColor(colors.white)
  66. term.clear()
  67.  
  68. term.setCursorPos(1, 8)
  69. write("Doom by Xelostar installer. Where do you want Doom to be installed? Path:")
  70.  
  71. term.setCursorPos(1, 11)
  72. write("Path: ")
  73. local path = read()
  74.  
  75. term.clear()
  76. term.setCursorPos(13, 2)
  77. term.setTextColor(colors.yellow)
  78. write("Doom by Xelostar installer")
  79.  
  80. local oldpath = shell.dir()
  81. shell.setDir("/")
  82. local installpath = "/"..fs.combine(path, "Doom")
  83. update("Installing...")
  84. bar(0)
  85.  
  86. update("Creating directories...")
  87. fs.makeDir(installpath)
  88. bar(0.02)
  89. fs.makeDir(fs.combine(installpath, "images"))
  90. bar(0.04)
  91. fs.makeDir(fs.combine(installpath, "levels"))
  92. bar(0.06)
  93. fs.makeDir(fs.combine(installpath, "models"))
  94. bar(0.08)
  95. update("Downloading license...")
  96. download("LICENSE", "/"..fs.combine(installpath, "LICENSE"))
  97. bar(0.10)
  98. update("Downloading game...")
  99. download("Doom/Doom", "/"..fs.combine(installpath, "Doom"))
  100. bar(0.12)
  101.  
  102. update("Downloading APIs...")
  103. download("Doom/ThreeD", "/"..fs.combine(installpath, "ThreeD"))
  104. bar(0.17)
  105. download("Doom/bufferAPI", "/"..fs.combine(installpath, "bufferAPI"))
  106. bar(0.22)
  107. pastebinD("ujchRSnU", "/"..fs.combine(installpath, "blittle"))
  108. bar(0.27)
  109.  
  110. update("Downloading images...")
  111. download("Doom/images/bfire", "/"..fs.combine(fs.combine(installpath, "images"), "bfire"))
  112. bar(0.30)
  113. download("Doom/images/bgun", "/"..fs.combine(fs.combine(installpath, "images"), "bgun"))
  114. bar(0.33)
  115. download("Doom/images/bgunf", "/"..fs.combine(fs.combine(installpath, "images"), "bgunf"))
  116. bar(0.36)
  117. download("Doom/images/bheart", "/"..fs.combine(fs.combine(installpath, "images"), "bheart"))
  118. bar(0.39)
  119. download("Doom/images/fire", "/"..fs.combine(fs.combine(installpath, "images"), "fire"))
  120. bar(0.42)
  121. download("Doom/images/gun", "/"..fs.combine(fs.combine(installpath, "images"), "gun"))
  122. bar(0.45)
  123. download("Doom/images/gunf", "/"..fs.combine(fs.combine(installpath, "images"), "gunf"))
  124. bar(0.48)
  125. download("Doom/images/heart", "/"..fs.combine(fs.combine(installpath, "images"), "heart"))
  126. bar(0.51)
  127. download("Doom/images/logo", "/"..fs.combine(fs.combine(installpath, "images"), "logo"))
  128. bar(0.54)
  129.  
  130. update("Downloading levels...")
  131. download("Doom/levels/level1", "/"..fs.combine(fs.combine(installpath, "levels"), "level1"))
  132. bar(0.57)
  133. download("Doom/levels/level2", "/"..fs.combine(fs.combine(installpath, "levels"), "level2"))
  134. bar(0.60)
  135. download("Doom/levels/level3", "/"..fs.combine(fs.combine(installpath, "levels"), "level3"))
  136. bar(0.63)
  137. download("Doom/levels/level4", "/"..fs.combine(fs.combine(installpath, "levels"), "level4"))
  138. bar(0.66)
  139. download("Doom/levels/level5", "/"..fs.combine(fs.combine(installpath, "levels"), "level5"))
  140. bar(0.69)
  141. download("Doom/levels/level6", "/"..fs.combine(fs.combine(installpath, "levels"), "level6"))
  142. bar(0.72)
  143. download("Doom/levels/level7", "/"..fs.combine(fs.combine(installpath, "levels"), "level7"))
  144. bar(0.75)
  145. download("Doom/levels/level8", "/"..fs.combine(fs.combine(installpath, "levels"), "level8"))
  146. bar(0.78)
  147. download("Doom/levels/level9", "/"..fs.combine(fs.combine(installpath, "levels"), "level9"))
  148. bar(0.81)
  149.  
  150. update("Downloading models...")
  151. download("Doom/models/corpse", "/"..fs.combine(fs.combine(installpath, "models"), "corpse"))
  152. bar(0.84)
  153. download("Doom/models/doorx", "/"..fs.combine(fs.combine(installpath, "models"), "doorx"))
  154. bar(0.86)
  155. download("Doom/models/doorz", "/"..fs.combine(fs.combine(installpath, "models"), "doorz"))
  156. bar(0.88)
  157. download("Doom/models/wallx", "/"..fs.combine(fs.combine(installpath, "models"), "wallx"))
  158. bar(0.90)
  159. download("Doom/models/wallz", "/"..fs.combine(fs.combine(installpath, "models"), "wallz"))
  160. bar(0.92)
  161. download("Doom/models/wallxz", "/"..fs.combine(fs.combine(installpath, "models"), "wallxz"))
  162. bar(0.93)
  163. download("Doom/models/emerald", "/"..fs.combine(fs.combine(installpath, "models"), "emerald"))
  164. bar(0.95)
  165. download("Doom/models/enemy1", "/"..fs.combine(fs.combine(installpath, "models"), "enemy1"))
  166. bar(0.97)
  167. download("Doom/models/enemy2", "/"..fs.combine(fs.combine(installpath, "models"), "enemy2"))
  168. bar(0.99)
  169.  
  170. update("Finishing installation...")
  171. fs.delete("/.std_list")
  172. fs.delete("/.std_websites")
  173.  
  174. update("Installation finished!")
  175. bar(1)
  176. shell.setDir(oldpath)
  177.  
  178. sleep(1)
  179. term.setBackgroundColor(colors.black)
  180. term.setTextColor(colors.white)
  181.  
  182. term.clear()
  183. term.setCursorPos(1, 1)
  184. write("Finished installation!\nPress any key to close...")
  185. os.pullEventRaw()
  186.  
  187. term.clear()
  188. term.setCursorPos(1, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement