Advertisement
vvenaya

AEmonitor

Sep 14th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. local mon=peripheral.wrap("monitor_2")
  2. local ae=peripheral.wrap("appeng_me_tilecontroller_0")
  3.  
  4. local mon_h,mon_v=mon.getSize()
  5.  
  6. local timer=os.startTimer(5)
  7.  
  8. local function setupScreen()
  9. mon.setBackgroundColor(colours.black)
  10. mon.clear()
  11. mon.setCursorPos(1,mon_v)
  12. mon.setBackgroundColor(colours.white)
  13. mon.setTextColor(colours.black)
  14. mon.write(string.rep(" ",mon_h))
  15. mon.setCursorPos(2,mon_v)
  16. mon.write("AE")
  17. end
  18.  
  19. local function iif(c,y,n)
  20. if c then return y end
  21. return n
  22. end
  23.  
  24.  
  25. local function updateMonitorAE()
  26. local freeBytes = 0 + ae.getFreeBytes()
  27. local totalBytes = 0 + ae.getTotalBytes()
  28. mon.setCursorPos(5,mon_v)
  29. mon.setBackgroundColor(colours.white)
  30. mon.setTextColor(iif(freeBytes>totalBytes/2,colors.black,iif(freeBytes<1000,colors.red,colours.green)))
  31. mon.write(ae.getFreeBytes())
  32. mon.setTextColor(colors.black)
  33. mon.write("/"..ae.getTotalBytes().." Bytes ")
  34. mon.write(" "..ae.getStoredItemCount().." Items stored ")
  35. end
  36.  
  37. setupScreen()
  38. updateMonitorAE()
  39.  
  40. while true do
  41. local e,p = os.pullEvent()
  42. if e=="timer" and p==timer then
  43. updateMonitorAE()
  44. sleep(5)
  45. end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement