Advertisement
CryptekCoding

[LUA]Matrix

Jun 25th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. term.redirect(peripheral.wrap("back"))
  2. term.setTextColor(colors.lime)
  3. local size={term.getSize()}
  4. local tPixels={}
  5. for x=1,size[1]-1 do
  6. tPixels[x]={}
  7. for y=1,size[2] do
  8. tPixels[x][y]=' '
  9. end
  10. end
  11. local function render()
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. for y=1,#tPixels[1] do
  15. if y~=1 then
  16. print('')
  17. end
  18. for x=1,#tPixels do
  19. write(tPixels[x][y])
  20. end
  21. end
  22. end
  23. local function cycle()
  24. for x=1,#tPixels do
  25. for y=#tPixels[x],2,-1 do
  26. tPixels[x][y]=(tPixels[x][y-1]==' ' and ' ') or ((tPixels[x][y]~=' ' and tPixels[x][y]) or string.char(math.random(32,126)))
  27. end
  28. --[[for x=1,#tPixels do
  29. local intC=nil
  30. for y=2,5 do
  31. if tPixels[x][y]==' ' then
  32. intC=true
  33. end
  34. end
  35. if not intC then
  36. tPixels[x][1]=' '
  37. end
  38. end]]
  39. end
  40. end
  41. local function create()
  42. tPixels[math.random(1,#tPixels)][1]=string.char(math.random(32,126))
  43. tPixels[math.random(1,#tPixels)][1]=' '
  44. tPixels[math.random(1,#tPixels)][1]=' '
  45. end
  46. local bRunning=true
  47. while bRunning do
  48. cycle()
  49. create()
  50. render()
  51. local timer=os.startTimer(.1)
  52. while true do
  53. local sEvent, param = os.pullEvent()
  54. if (sEvent=='timer' and param==timer) then
  55. break
  56. end
  57. end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement