Advertisement
Macsmith

turbine

Oct 30th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.43 KB | None | 0 0
  1. --Big reactors turbine program: Set rpm a little lower than your turbine optimun rpm
  2. local turbine = peripheral.wrap("BigReactors-Turbine_0")
  3. local mon = peripheral.wrap("top")
  4. local rpm = 1775
  5. local autocoil = 1
  6. local x = 0
  7. local y = 0
  8.  
  9. local function main()
  10.   while true do
  11.     mon.clear()
  12.     mon.setCursorPos(1,1)
  13.     mon.setTextColor(colors.white)
  14.     mon.write("Active:")
  15.     if turbine.getActive() then
  16.       mon.setBackgroundColor(colors.green)
  17.       mon.write(" True")
  18.     else
  19.       mon.setBackgroundColor(colors.red)
  20.       mon.setTextColor(colors.black)
  21.       mon.write(" False")
  22.     end
  23.     mon.setBackgroundColor(colors.black)
  24.  
  25.     mon.setCursorPos(1,2)
  26.     mon.setTextColor(colors.white)
  27.     mon.write("Coils engaged:")
  28.     if turbine.getInductorEngaged() then
  29.       mon.setBackgroundColor(colors.green)
  30.       mon.write(" True")
  31.     else
  32.       mon.setBackgroundColor(colors.red)
  33.       mon.setTextColor(colors.black)
  34.       mon.write(" False")
  35.     end
  36.     mon.setBackgroundColor(colors.black)
  37.    
  38.     mon.setCursorPos(1,3)
  39.     mon.setTextColor(colors.white)
  40.     mon.write("RF/t: ")
  41.     mon.setTextColor(colors.lime)
  42.     mon.write(math.floor(turbine.getEnergyProducedLastTick()))
  43.  
  44.     mon.setCursorPos(1,4)
  45.     mon.setTextColor(colors.white)
  46.     mon.write("RF Stored: ")
  47.     mon.setTextColor(colors.lime)
  48.     mon.write(math.floor(turbine.getEnergyStored()))
  49.  
  50.     mon.setCursorPos(1,5)
  51.     mon.setTextColor(colors.white)
  52.     mon.write("Rotor Speed: ")
  53.     mon.setTextColor(colors.lime)
  54.     mon.write(tostring(turbine.getRotorSpeed()))
  55.     mon.write(" RPM")
  56.  
  57.     mon.setCursorPos(1,6)
  58.     mon.setTextColor(colors.white)
  59.     mon.write("Steam flow: ")
  60.     mon.setTextColor(colors.lime)
  61.     mon.write(turbine.getFluidFlowRate())
  62.     mon.write(" mB/t")
  63.  
  64.     mon.setCursorPos(1,7)
  65.     mon.setTextColor(colors.white)
  66.     mon.write("Max flow: ")
  67.     mon.setTextColor(colors.lime)
  68.     mon.write(turbine.getFluidFlowRateMax())
  69.     mon.write(" mB/t")
  70.    
  71.     mon.setCursorPos(1,8)
  72.     mon.setTextColor(colors.white)
  73.     mon.write("Auto-coil:")
  74.     if autocoil == 1 then
  75.       mon.setBackgroundColor(colors.green)
  76.       mon.write(" True")
  77.       if turbine.getRotorSpeed() < rpm and turbine.getActive() then
  78.         turbine.setInductorEngaged(false)
  79.       else
  80.         if not turbine.getInductorEngaged() then
  81.           turbine.setInductorEngaged(true)
  82.         end
  83.       end
  84.     else
  85.       mon.setBackgroundColor(colors.red)
  86.       mon.setTextColor(colors.black)
  87.       mon.write(" False")                
  88.     end
  89.     mon.setBackgroundColor(colors.black)
  90.    
  91.        
  92.     if (x >= 8) and (x <= 13) and (y == 1) then
  93.       if turbine.getActive() then
  94.         turbine.setActive(false)
  95.       else
  96.         turbine.setActive(true)
  97.       end
  98.     x = 0
  99.     y = 0
  100.     end
  101.    
  102.     if x >= 15 and x <= 20 and y == 2 then
  103.       if autocoil == 0 then
  104.         if turbine.getInductorEngaged() then
  105.           turbine.setInductorEngaged(false)
  106.         else
  107.           turbine.setInductorEngaged(true)
  108.         end
  109.       end
  110.       x = 0
  111.       y = 0
  112.     end
  113.    
  114.    
  115.     if x >= 11 and x <= 16 and y == 8 then
  116.       if autocoil == 1 then
  117.         autocoil = 0
  118.       else
  119.         autocoil = 1
  120.       end
  121.       x = 0
  122.       y = 0
  123.     end
  124.  
  125.     sleep(1)
  126.   end  
  127. end
  128.  
  129. local function touch()
  130.   while true do
  131.     _, _, x, y = os.pullEvent("monitor_touch")
  132.   end
  133. end
  134.  
  135. parallel.waitForAny(main,touch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement