Advertisement
EmberQuill

ComputerCraft Energy Cell Monitor

May 5th, 2013
2,829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. local cell1 = peripheral.wrap("right")
  2. local cell2 = peripheral.wrap("left")
  3. local transmitter = peripheral.wrap("top")
  4. local monitor = peripheral.wrap("back")
  5. local charging1 = false
  6. local charging2 = false
  7.  
  8. monitor.clear()
  9. monitor.setTextColor(512)
  10. monitor.setCursorPos(6,3)
  11. monitor.write("Power System Status")
  12.  
  13. monitor.setTextColor(1)
  14. monitor.setCursorPos(5,5)
  15. monitor.write("Cell 1")
  16. monitor.setCursorPos(20,5)
  17. monitor.write("Cell 2")
  18. monitor.setCursorPos(12,8)
  19. monitor.write("Engines")
  20.  
  21. transmitter.setFreq(1)
  22.  
  23. while(true) do
  24.     data1 = cell1.get()
  25.     data2 = cell2.get()
  26.  
  27.     monitor.setCursorPos(1,6)
  28.     monitor.clearLine()
  29.     monitor.setCursorPos(1,9)
  30.     monitor.clearLine()
  31.    
  32.     if data1["Full Energy"] then
  33.         monitor.setCursorPos(6,6)
  34.         monitor.setTextColor(32)
  35.         monitor.write("Full")
  36.         charging1 = false
  37.     elseif data1["No Energy"] then
  38.         monitor.setCursorPos(5,6)
  39.         monitor.setTextColor(16384)
  40.         monitor.write("Empty")
  41.         charging1 = true
  42.     elseif data1["Energy Stored"] and data1["Can Store Energy"] then
  43.         monitor.setCursorPos(4,6)
  44.         if charging1 then
  45.             monitor.setTextColor(16)
  46.             monitor.write("Charging")
  47.         else
  48.             monitor.setTextColor(2)
  49.             monitor.write("Draining")
  50.         end
  51.     else
  52.         monitor.setCursorPos(5,6)
  53.         monitor.setTextColor(16384)
  54.         monitor.write("ERROR")
  55.     end
  56.    
  57.     if data2["Full Energy"] then
  58.         monitor.setCursorPos(21,6)
  59.         monitor.setTextColor(32)
  60.         monitor.write("Full")
  61.         charging2 = false
  62.     elseif data2["No Energy"] then
  63.         monitor.setCursorPos(20,6)
  64.         monitor.setTextColor(16384)
  65.         monitor.write("Empty")
  66.         charging2 = true
  67.     elseif data2["Energy Stored"] and data2["Can Store Energy"] then
  68.         monitor.setCursorPos(19,6)
  69.         if charging2 then
  70.             monitor.setTextColor(16)
  71.             monitor.write("Charging")
  72.         else
  73.             monitor.setTextColor(2)
  74.             monitor.write("Draining")
  75.         end
  76.     else
  77.         monitor.setCursorPos(20,6)
  78.         monitor.setTextColor(16384)
  79.         monitor.write("ERROR")
  80.     end
  81.    
  82.     if charging1 and charging2 then
  83.         redstone.setOutput("top",true)
  84.         monitor.setCursorPos(12,9)
  85.         monitor.setTextColor(32)
  86.         monitor.write("Running")
  87.     elseif not charging1 and not charging2 then
  88.         redstone.setOutput("top",false)
  89.         monitor.setCursorPos(14,9)
  90.         monitor.setTextColor(16384)
  91.         monitor.write("Off")
  92.     end
  93.     sleep(1)
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement