Advertisement
Sharidan

CC cable network distance test

May 30th, 2015
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local function mainLoop()
  2.   local running = true
  3.   local t = os.startTimer(1)
  4.   while running do
  5.     local event, p1, p2, p3, p4, p5 = os.pullEvent()
  6.     if (event == "timer" and p1 == t) then
  7.       local lst = peripheral.getNames()
  8.       local mcTime = textutils.formatTime(os.time(), true)
  9.       print(mcTime)
  10.       for l = 1, #lst do
  11.         if (peripheral.getType(lst[l]) == "monitor") then
  12.           local mon = peripheral.wrap(lst[l])
  13.           mon.setTextColor(colors.white)
  14.           mon.setBackgroundColor(colors.black)
  15.           mon.clear()
  16.           local w, h = mon.getSize()
  17.           local x = math.floor((w - #mcTime) / 2) + 1
  18.           local y = math.floor((h - 1) / 2) + 1
  19.           mon.setCursorPos(x, y)
  20.           mon.write(mcTime)
  21.           mon = nil
  22.         end
  23.       end
  24.       lst = nil
  25.       mcTime = nil
  26.       t = os.startTimer(1)
  27.     elseif (event == "char") then
  28.       local c = string.lower(p1)
  29.       if (c == "q") then
  30.         running = nil
  31.       end
  32.     end
  33.   end
  34. end
  35.  
  36. mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement