Simlor_GER

SimSoft Yellow - Random Background Program

Jun 17th, 2017 (edited)
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. --Program by Simlor (http://www.computercraft.info/forums2/index.php?/user/55655-simlor/)
  2.  
  3. function Download(CodePB, Pfad)
  4. local cacheBuster = ("%x"):format(math.random(0, 2 ^ 30))
  5. local datei = http.get("https://pastebin.com/raw/" .. textutils.urlEncode(CodePB) .. "?cb=" .. cacheBuster)
  6. datei = datei.readAll()
  7.  
  8. local file = fs.open(Pfad, "w")
  9. file.write(datei)
  10. file.close()
  11.  
  12. end
  13.  
  14. --Random Background
  15.  
  16. BC(128)
  17. Clear()
  18.  
  19. TC(SystemColor)
  20.  
  21. CP(1,1)
  22. print("Random Background Program!")
  23.  
  24. TC(1)
  25.  
  26. CP(1,3)
  27. print("Generate a number...")
  28.  
  29. sleep(1)
  30.  
  31. Download("JTBbFypQ", "BacklisteTEMP")
  32.  
  33. file = fs.open("BacklisteTEMP","r")
  34. local fileData = {}
  35. local line = file.readLine()
  36. repeat
  37. table.insert(fileData,line)
  38. line = file.readLine()
  39. until line == nil
  40. file.close()
  41.  
  42. MAXC = fileData[1]
  43.  
  44. MAXC = (MAXC+0)
  45.  
  46. number = math.random(3,MAXC)
  47.  
  48. CP(1,4)
  49. print("You got the number... "..(number-2).."!")
  50.  
  51. CP(1,5)
  52. print("Downloading Background...")
  53.  
  54. fs.delete("SimSoft/Data/Background")
  55.  
  56. Download((fileData[number]),"SimSoft/Data/Background")
  57.  
  58. TC(SystemColor)
  59. CP(1,7)
  60. print("Here is your 'new' background!")
  61.  
  62. sleep(2)
  63.  
  64. --end
Add Comment
Please, Sign In to add comment