Advertisement
avartoon15

Untitled

Jan 9th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.74 KB | None | 0 0
  1. capI = peripheral.wrap("cofh_thermalexpansion_energycell_0")
  2. capII = peripheral.wrap("cofh_thermalexpansion_energycell_1")
  3. y = 0
  4. z = 0
  5. function cap_1()
  6.   cap1 = capI.getEnergyStored("nort") / capI.getMaxEnergyStored("north")
  7.   cap1 = cap1 * 100
  8. end
  9.  
  10. function cap_2()
  11.   cap2 = capII.getEnergyStored("north") / capII.getMaxEnergyStored("north")
  12.   cap2 = cap2 * 100
  13. end
  14.  
  15. function redstone()
  16.   if rs.testBundledInput("left", colors.blue) == true then
  17.     x = 1
  18.     y = 0
  19.     rs.setOutput("right", true)
  20.   else
  21.     if (rs.testBundledInput("left", colors.white) == false) and (z == 0) then
  22.       if cap1  > 90 then
  23.          rs.setOutput("right", false)
  24.          x = 0
  25.          if y == 0 then
  26.            rs.setOutput("top", true)
  27.            sleep(1)
  28.            rs.setOutput("top", false)
  29.             y = 1
  30.          end
  31.       elseif cap1 < 30 then
  32.          rs.setOutput("right", true)
  33.          x = 1
  34.          y = 0
  35.       end
  36.     else
  37.        rs.setOutput("right", true)
  38.        x = 1
  39.        y = 0
  40.        if rs.testBundledInput("left", colors.orange) == false then
  41.          z = 0
  42.        else
  43.          z = 1
  44.        end
  45.      end
  46.   end
  47. end
  48.  
  49. function energy()
  50.   io1 = capII.getEnergyStored("north")
  51.   sleep(1)
  52.   io2 = capII.getEnergyStored("north")
  53.   IO = io2 - io1
  54. end
  55.  
  56. function monitor()
  57.  energy()
  58.  m.clear()
  59.  m.setBackgroundColor(59)
  60.  m.setTextColor(1875)
  61.    m.setCursorPos(15,12)
  62.   if IO > 0 then
  63.     m.write("Input: " ..IO)
  64.   else
  65.     m.write("Output: " ..IO)
  66.   end
  67.   m.setCursorPos(15,3)
  68.   m.write("Energy Stored")
  69.   m.setCursorPos(15,4)
  70.   m.write("capacitor II.")
  71.   m.setCursorPos(15,5)
  72.   m.write(capII.getEnergyStored("north"))
  73.   m.setCursorPos(15,6)
  74.   m.write(cap2.. "%")
  75.   m.setCursorPos(15,9)
  76.   m.write("capacitor I.")
  77.   m.setCursorPos(15,10)
  78.   m.write(capI.getEnergyStored("north"))
  79.   m.setCursorPos(15,11)
  80.   m.write(cap1.. "%")
  81.   m.setCursorPos(5,16)
  82.   if x == 0 then
  83.   m.write("Redstone signal: Off")
  84.   m.setCursorPos(5,17)
  85.   m.write("Quarry: On")
  86.   m.setCursorPos(5,15)
  87.   m.write("Buffer: Low")
  88.   else
  89.    if y == 0 then
  90.      m.write("Redstone signal: On")
  91.      m.setCursorPos(5,15)
  92.      m.write("Buffer: Empty")
  93.    else
  94.      if z == 0 then
  95.        m.write("Redstone signal: Off-Low energy")
  96.        m.setCursorPos(5,15)
  97.        m.write("Buffer: Empty")
  98.      else
  99.        m.write("Redstone signal: On")
  100.        m.setCursorPos(5,15)
  101.        m.write("Buffer: Full")
  102.      end
  103.    end
  104.   m.setCursorPos(5,17)
  105.   m.write("Quarry: Off")
  106.   end
  107. end
  108.  
  109. while true do
  110.   cap_1()
  111.   cap_2()
  112.   if rs.testBundledInput("left", colors.blue) == true then
  113.     y = 0
  114.   else
  115.     y = 1
  116.   end
  117.   redstone()
  118.   m = peripheral.wrap("monitor_0")
  119.   monitor()
  120.   m = peripheral.wrap("monitor_1")
  121.   monitor()
  122.   sleep(1)
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement