Advertisement
guitarplayer616

BUFFER READER

Jun 23rd, 2015
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local buffer = {}
  2. local w,h = term.getSize()
  3.  
  4. function initBuffer()
  5.         for x=1,w do
  6.                 buffer[x] = {}
  7.                 for y = 1,h do
  8.                         buffer[x][y] = {}
  9.                 end
  10.         end
  11. end
  12.  
  13. function displayBuffer()
  14.         for x = 1, #buffer do
  15.                 for y = 1, #buffer[x] do
  16.                         term.setCursorPos(x,y)
  17.                         if #buffer[x][y] == 3 then
  18.                                 term.setTextColor(buffer[x][y][2])
  19.                                 term.setBackgroundColor(buffer[x][y][3])
  20.                                 term.write(buffer[x][y][1])
  21.                         end
  22.                 end
  23.         end
  24. end
  25.  
  26. initBuffer()
  27. shell.run("clr")
  28. while true do
  29.     s = {rednet.receive("stream")}
  30.     buffer = textutils.unserialize(s[2])
  31.     displayBuffer()
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement