Advertisement
ValveCantCount

upb-update

May 6th, 2015
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. function cprint(...)
  2.         local s = "&1"
  3.         for k, v in ipairs(arg) do
  4.                 s = s .. v
  5.         end
  6.         s = s .. "&0"
  7.  
  8.         local fields = {}
  9.         local lastcolor, lastpos = "0", 0
  10.         for pos, clr in s:gmatch"()&(%x)" do
  11.                 table.insert(fields, {s:sub(lastpos + 2, pos - 1), lastcolor})
  12.                 lastcolor, lastpos = clr , pos
  13.         end
  14.  
  15.         for i = 2, #fields do
  16.                 term.setTextColor(2 ^ (tonumber(fields[i][2], 16)))
  17.                 io.write(fields[i][1])
  18.         end
  19. end
  20.  
  21. cprint("&1Getting Updated Version...  \n\n")
  22. shell.run("pastebin", "get", "dGA50rfG", ".userpastebin.updated")
  23. cprint("\n&1")
  24. if fs.exists(shell.resolve(".userpastebin.updated")) == true then
  25.     cprint("&1Success!\n")
  26. else
  27.     cprint("&1Failed!&0\n")
  28.     return
  29. end
  30. if fs.exists(shell.resolve("userpastebin")) == true then
  31.     cprint("&1Removing Old Version...  ")
  32.     shell.run("rm", "userpastebin")
  33.     if fs.exists(shell.resolve("userpastebin")) == false then
  34.         cprint("&1Success!\n")
  35.     else
  36.         cprint("&1Failed!&0\n")
  37.         return
  38.     end
  39. end
  40. cprint("&1Renaming Updated Version...  ")
  41. shell.run("rename", ".userpastebin.updated", "userpastebin")
  42. if fs.exists(shell.resolve("userpastebin")) == true then
  43.     cprint("&1Success!&0\n")
  44.     shell.run("userpastebin", "update", "rm")
  45. else
  46.     cprint("&1Failed!&0\n")
  47.     return
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement