Advertisement
bliind

Untitled

Jul 5th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. turbine = peripheral.wrap("back")
  2. optimalRotorSpeed = 1800
  3. rotorVariance = 10
  4. maxFlowRate = 2000
  5. leastFlowRate = 500
  6.  
  7. capacitor = peripheral.wrap("tile_blockcapacitorbank_name_1")
  8. capacitorCount = 3
  9. capacitorCapacity = 25000000
  10. totalCapacity = (capacitorCount * capacitorCapacity)
  11. powerVariance = 5000000
  12.  
  13. function engage(bool)
  14. turbine.setInductorEngaged(bool)
  15. end
  16.  
  17. function power(bool)
  18. turbine.setActive(bool)
  19. end
  20.  
  21. function lower(cur)
  22. turbine.setFluidFlowRateMax((cur-100))
  23. end
  24.  
  25. function higher(cur)
  26. turbine.setFluidFlowRateMax((cur+100))
  27. end
  28.  
  29. while true do
  30. on = turbine.getActive()
  31. engaged = turbine.getInductorEngaged()
  32. curSpeed = turbine.getRotorSpeed()
  33. steamAmount = turbine.getInputAmount()
  34. flowRate = turbine.getFluidFlowRateMax()
  35. flowMax = (flowRate==maxFlowRate)
  36. flowLeast = (flowRate==leastFlowRate)
  37. rotorLow = (curSpeed<(optimalRotorSpeed-rotorVariance))
  38. rotorGood = (curSpeed==optimalRotorSpeed)
  39. rotorHigh = (curSpeed>(optimalRotorSpeed+rotorVariance))
  40. steamLow = (steamAmount<flowRate)
  41. steamHigh = (steamAmount>=flowRate)
  42. energy = capacitor.getEnergyStored()
  43. actualEnergy = (energy * capacitorCount)
  44. energyFull = (actualEnergy>=(totalCapacity-powerVariance))
  45.  
  46. if on then
  47. if engaged then
  48. if rotorLow then
  49. if flowMax then
  50. engage(false)
  51. else
  52. higher(flowRate)
  53. sleep(1)
  54. end
  55. end
  56. if rotorHigh then
  57. lower(flowRate)
  58. sleep(1)
  59. end
  60. else
  61. if rotorGood or rotorHigh then
  62. engage(true)
  63. end
  64. end
  65. if steamLow then
  66. if rotorLow then
  67. engage(false)
  68. end
  69. if flowLeast then
  70. power(false)
  71. else
  72. lower(flowRate)
  73. end
  74. end
  75. else
  76. if steamHigh and not energyFull then
  77. power(true)
  78. end
  79. end
  80.  
  81. if energyFull then
  82. power(false)
  83. engage(false)
  84. end
  85.  
  86. sleep(1)
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement