Advertisement
bliind

Untitled

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