Advertisement
Sayomie550

Untitled

Mar 25th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. --[[
  2. Turbine Control v1.0
  3.     lT = Large Turbine
  4.     sT = Small Turbine
  5.    
  6.     Displays power output and auto adjusts turbine speed
  7. --]]
  8.  
  9. lT1 = peripheral.wrap("BigReactors-Turbine_5")
  10. lT2 = peripheral.wrap("BigReactors-Turbine_15")
  11. lT3 = peripheral.wrap("BigReactors-Turbine_16")
  12. lT4 = peripheral.wrap("BigReactors-Turbine_4")
  13. lT5 = peripheral.wrap("BigReactors-Turbine_17")
  14. lT6 = peripheral.wrap("BigReactors-Turbine_18")
  15. lT7 = peripheral.wrap("BigReactors-Turbine_6")
  16. lT8 = peripheral.wrap("BigReactors-Turbine_19")
  17. sT1 = peripheral.wrap("BigReactors-Turbine_7")
  18. sT2 = peripheral.wrap("BigReactors-Turbine_8")
  19. sT3 = peripheral.wrap("BigReactors-Turbine_9")
  20. sT4 = peripheral.wrap("BigReactors-Turbine_10")
  21. sT5 = peripheral.wrap("BigReactors-Turbine_11")
  22. sT6 = peripheral.wrap("BigReactors-Turbine_12")
  23. sT7 = peripheral.wrap("BigReactors-Turbine_13")
  24. sT8 = peripheral.wrap("BigReactors-Turbine_14")
  25. local lPower = 0
  26. local sPower = 0
  27. local oPower = 0
  28.  
  29. while true do
  30.     --Gather the power production levels
  31.     lPower = lT1.getEnergyProducedLastTick()
  32.     sPower = sT1.getEnergyProducedLastTick()
  33.     oPower = lPower + sPower
  34.    
  35.    
  36.     --Display the power production and turbine status
  37.     if lT1.getActive() then
  38.         lA1 = ("True")
  39.     else
  40.         lA1 = ("False")
  41.     end
  42.    
  43.     function display()
  44.         term.clear()
  45.         term.setCursorPos(1,1)
  46.         print("Large Turbine Power Output (RF/t) - " ..lPower)
  47.         print("Small Turbine Power Output (RF/t) - " ..sPower)
  48.         print("Overall Power Output (RF/t) - " ..oPower)
  49.         print("Large Turbine 1 Active - " ..lA1)
  50.         --[[
  51.         print("Large Turbine 2 Active - " ..lA2)
  52.         print("Large Turbine 3 Active - " ..lT3.getActive())
  53.         print("Large Turbine 4 Active - " ..lT4.getActive())
  54.         print("Large Turbine 5 Active - " ..lT5.getActive())
  55.         print("Large Turbine 6 Active - " ..lT6.getActive())
  56.         print("Large Turbine 7 Active - " ..lT7.getActive())
  57.         print("Large Turbine 8 Active - " ..lT8.getActive())
  58.         print("Small Turbine 1 Active - " ..sT1.getActive())
  59.         print("Small Turbine 2 Active - " ..sT2.getActive())
  60.         print("Small Turbine 3 Active - " ..sT3.getActive())
  61.         print("Small Turbine 4 Active - " ..sT4.getActive())
  62.         print("Small Turbine 5 Active - " ..sT5.getActive())
  63.         print("Small Turbine 6 Active - " ..sT6.getActive())
  64.         print("Small Turbine 7 Active - " ..sT7.getActive())
  65.         print("Small Turbine 8 Active - " ..sT8.getActive())
  66.         --]]
  67.     end
  68.    
  69.     --Stops and starts the turbines based on internal storage levels
  70.     if lT1.getEnergyStored() >= 980000 then
  71.         lT1.setActive(false)
  72.     else
  73.         lT1.setActive(true)
  74.     end
  75.    
  76.     --Auto adjust of the Large turbines
  77.     lT1Speed = lT1.getRotorSpeed()
  78.     lT1Flow = lT1.getFluidFlowRate()
  79.     if lT1Speed > 1850 then
  80.         lT1.setFluidFlowRateMax = lT1Flow + 1
  81.     end
  82.     if lT1Speed < 1820 then
  83.         lT1.setFluidFlowRateMax = lT1Flow - 1
  84.     end
  85.    
  86.     display()
  87.     sleep(5)
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement