Guest User

Untitled

a guest
Apr 5th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. -- Clears screen, sets cursor position
  2.  
  3. term.clear()
  4.  
  5. term.setCursorPos(1,1)
  6.  
  7.  
  8.  
  9. -- Sets maxx and maxy for screen resolution
  10.  
  11. maxx, maxy = term.getSize()
  12.  
  13.  
  14.  
  15. -- Sets maxr as the maximum of randomization
  16.  
  17. maxr = 4
  18.  
  19.  
  20.  
  21. -- Creates an empty table
  22.  
  23. all = {}
  24.  
  25.  
  26.  
  27.  
  28. -- Sets for every pixel 1 or 0
  29.  
  30. -- i are the lines, j are the pixels in a line
  31.  
  32. for i = 1, maxx do
  33.  
  34. all[i] = {}
  35.  
  36. for j = 1, maxy do
  37.  
  38. r = math.random(0, maxr)
  39.  
  40. if r > 1 then
  41.  
  42. r = 0
  43.  
  44. end
  45.  
  46. all[i][j] = r
  47.  
  48. end
  49.  
  50. end
  51.  
  52. -- Fills the entire screen with the pixels
  53.  
  54. -- from the table
  55. for i = 1, #all do
  56.  
  57. for j = 1, #all[i] do
  58.  
  59. if all[i][j] == 1 then
  60.  
  61. term.setBackgroundColor(colors.black)
  62.  
  63. term.setTextColor(colors.black)
  64.  
  65. else
  66.  
  67. term.setBackgroundColor(colors.white)
  68.  
  69. term.setTextColor(colors.white)
  70.  
  71. end
  72.  
  73. --
  74.  
  75. -- this works well as long as it's all[i][j]
  76.  
  77. write(all[i][j])
  78.  
  79. -- now try to change it to " "
  80.  
  81. --
  82.  
  83. sleep(0.01)
  84.  
  85. end
  86.  
  87. end
  88.  
  89.  
  90.  
  91.  
  92.  
  93. -- just to let you see the outcome
  94.  
  95. sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment