Advertisement
Agent_Silence

Matrix

Jun 9th, 2014 (edited)
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. codes = {}
  2. function randGreen()
  3. local a = math.random(1,2)
  4. if a == 1 then
  5. return colors.lime
  6. elseif a == 2 then
  7. return colors.green
  8. end
  9. end
  10.  
  11. function newCode()
  12. local template = {
  13. x = math.random(1,51),
  14. size = math.random(1,4),
  15. y = 0,
  16. color = randGreen()
  17. }
  18. template.y = 1 - template.size
  19. table.insert(codes,template)
  20. end
  21.  
  22. function increment(one,two)
  23. if one > two then
  24. return -1
  25. elseif one < two then
  26. return 1
  27. end
  28. end
  29.  
  30. function drawLine(sX,sY,eX,eY,tColor,bColor)
  31. paintutils.drawLine(sX,sY,eX,eY,bColor)
  32. term.setCursorPos(sX,sY)
  33. for i=sY,eY,increment(sY,eY) do
  34. term.setCursorPos(sX,i)
  35. term.setTextColor(tColor)
  36. term.write(string.char(math.random(33,126)))
  37. end
  38. end
  39.  
  40. function redraw()
  41. term.setBackgroundColor(colors.black)
  42. term.clear()
  43. for i,v in pairs(codes) do
  44. v.y = v.y + 1
  45. drawLine(v.x,v.y,v.x,v.y+v.size,colors.black,v.color)
  46. if v.y > 19 then
  47. table.remove(codes,i)
  48. end
  49. end
  50. end
  51.  
  52. while true do
  53. for i=1,3 do
  54. newCode()
  55. end
  56. redraw()
  57. sleep(0.1)
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement