Advertisement
systox

eu monitor

Aug 19th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. local modem = peripheral.wrap("right")
  2. local auth = 17138
  3. local mon = peripheral.wrap("top")
  4. local messages = {}
  5. local cooldown = 3
  6. local refreshtime = 1
  7.  
  8. list = {
  9. [17138] = {"Gesamt     ",1},
  10. [17153] = {"Hv-Maschie ",2},
  11. [17152] = {"Hv-Mesystem",3},
  12. [17150] = {"Me-System  ",4}
  13. }
  14.  
  15. os.startTimer(cooldown)
  16. modem.open(65535)
  17.  
  18. function moncc()
  19.     mon.clear()
  20.     mon.setCursorPos(1,1)
  21. end
  22.  
  23. while true do
  24.     local event, a1, a2, a3, a4, a5 = os.pullEvent()
  25.     if event == "modem_message" then
  26.         if list[tonumber(a3)] then
  27.             if messages[tonumber(a3)] then
  28.                 table.remove(messages,tonumber(a3))
  29.             end
  30.             table.insert(messages,tonumber(a3),a4)
  31.         end
  32.     elseif event == "timer" then
  33.         moncc()
  34.         mon.setCursorPos(3,2)
  35.         mon.setTextColor(colors.white); mon.write("----------------------------")
  36.         for k,v in pairs(messages) do
  37.             newv = textutils.unserialize(v)
  38.             mon.setCursorPos(3,2+list[k][2])
  39.            
  40.             value = math.floor(newv[1])
  41.            
  42.             mon.setTextColor(colors.lightGray); mon.write(list[k][1])
  43.             mon.setTextColor(colors.white); mon.write(": ")
  44.            
  45.             if value > 0 then
  46.                 mon.setTextColor(colors.lime)
  47.             else
  48.                 mon.setTextColor(colors.red)
  49.             end
  50.            
  51.             mon.write(value)
  52.             mon.setCursorPos(24,2+list[k][2])
  53.             mon.setTextColor(colors.white); mon.write(" eu/t")
  54.         end
  55.         os.startTimer(refreshtime)
  56.     end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement