Advertisement
ItsNoah

TurtleLog

Jan 26th, 2022
570
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local y = 0
  2. local log = {}
  3.  
  4. local function clt()
  5.     term.clear()
  6.     ty = 1
  7.     term.setCursorPos(1, ty)
  8. end
  9.  
  10. local function writeLine( content )
  11.     term.write(content)
  12.     ty = ty + 1
  13.     term.setCursorPos(1, ty)
  14. end
  15.  
  16. local function writeAt( line, content )
  17.     term.setCursorPos(1, line)
  18.     term.write(content)
  19. end
  20.  
  21. local function printc( content )
  22.     table.insert(log, content)
  23.  
  24.     clt()
  25.     writeAt(1, "======= Turtle Log =======")
  26.  
  27.     local off = #log - 18
  28.     if off < 1 then off = 0 end
  29.     for i = 18, 1, -1 do
  30.         if (i < #log+1) then
  31.             writeAt(i+1, log[i+off])
  32.         end
  33.     end
  34. end
  35.  
  36. -- start --
  37. printc("> Starting...")
  38. peripheral.find("modem", rednet.open)
  39.  
  40. repeat
  41.     local id, message = rednet.receive()
  42.     printc(message)
  43. until false
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement