TheKojent

Turbo Tree Monitor

Dec 29th, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. --[[
  2. Monitoring system for the TurboTree network
  3. Requires 1 computer, a 3 wide monitor array to the left, and 1 modem on the rear.
  4. ]]
  5.  
  6. m = peripheral.wrap("left") --Set up monitor
  7. m.setTextScale(1.5)
  8. m.clear()
  9.  
  10. rednet.open("back") --Set up router
  11.  
  12. local data = {{"logger1", "------", "away"}, {"sorter1", "------", "away"}, {"sorter2", "------", "away"}} --Set up data table with default values
  13.  
  14. local comp = {} --Table with adjusted computer IDs
  15. comp[4] = 1
  16. comp[12] = 2
  17. comp[7] = 3
  18.  
  19. local function updateScreen()
  20.     m.clear()
  21.     for i =1,3 do
  22.         m.setCursorPos(1,i)
  23.         m.write(data[i][1] .. " " .. data[i][2] .. " " .. data[i][3])
  24.     end
  25. end
  26.  
  27. while true do
  28.     updateScreen()
  29.     id, message = rednet.receive()
  30.     if id == 4 or id == 12 or id ==7 then
  31.         if message == "home" or message == "away" then
  32.             data[comp[id]][3] = message
  33.         elseif tonumber(message) then
  34.             local a = tonumber(message)
  35.             if a >= 10 then
  36.                 data[comp[id]][2] = message .. "mins"
  37.             elseif a == 1 then
  38.                 data[comp[id]][2] = " 1min "
  39.             else
  40.                 data[comp[id]][2] = " " .. message .. "mins"
  41.             end
  42.         end
  43.     end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment