Advertisement
michal_359

Untitled

Jul 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. ----------------------------------------
  2. --CONFIG
  3. ----------------------------------------
  4. speed = 1780
  5. steam = 2000
  6.  
  7. --value in %
  8. reactorOn = 50
  9. reactorOff = 90
  10. ----------------------------------------
  11.  
  12. local peripheralList = peripheral.getNames()
  13. amountTurbines = 0
  14. reactorNumber = 0
  15. t = {}
  16. r = {}
  17. for i = 1, #peripheralList do
  18. --Turbines
  19. if peripheral.getType(peripheralList[i]) == "BigReactors-Turbine" then
  20. t[amountTurbines] = peripheral.wrap(peripheralList[i])
  21. amountTurbines = amountTurbines + 1
  22. --Reactor
  23. elseif peripheral.getType(peripheralList[i]) == "BigReactors-Reactor" then
  24. r[reactorNumber] = peripheral.wrap(peripheralList[i])
  25. reactorNumber = reactorNumber + 1
  26. --Monitor & Touchpoint
  27. elseif peripheral.getType(peripheralList[i]) == "monitor" then
  28. mon = peripheral.wrap(peripheralList[i])
  29. touchpointLocation = peripheralList[i]
  30. --Capacitorbank / Energycell / Energy Core
  31. else
  32. local tmp = peripheral.wrap(peripheralList[i])
  33. local stat,err = pcall(function() tmp.getEnergyStored() end)
  34. if stat then
  35. v = tmp
  36. end
  37. end
  38. end
  39.  
  40. mon.setTextColor(colors.white)
  41. mon.setTextScale(1)
  42. term.setTextColor(colors.white)
  43.  
  44. local a = 1
  45. while a < amountTurbines do
  46. for i = 0, amountTurbines-1 do
  47. local tspeed = t[i].getRotorSpeed()
  48. if tspeed <= speed then
  49. for j = 0, reactorNumber-1 do
  50. r[j].setActive(true)
  51. end
  52. t[i].setActive(true)
  53. t[i].setInductorEngaged(false)
  54. t[i].setFluidFlowRateMax(steam)
  55. end
  56. if t[i].getRotorSpeed() > speed then
  57. t[i].setFluidFlowRateMax(0)
  58. end
  59. end
  60. a = 0
  61.  
  62. mon.clear()
  63. mon.setCursorPos(1,1)
  64. term.clear()
  65. term.setCursorPos(1,1)
  66.  
  67. for i = 0, amountTurbines-1 do
  68. b = i+1
  69. mon.setTextColor(colors.white)
  70. if t[i].getRotorSpeed() <= speed then
  71. term.setTextColor(colors.red)
  72. print("["..b.."]".." "..math.floor(t[i].getRotorSpeed()))
  73. end
  74. if t[i].getRotorSpeed() > speed then
  75. a = a+1
  76. end
  77. end
  78. sleep(1)
  79. end
  80. mon.setTextColor(colors.white)
  81. term.setTextColor(colors.white)
  82. for j = 0, reactorNumber-1 do
  83. r[j].setActive(false)
  84. end
  85. for i = 0, amountTurbines-1 do
  86. t[i].setInductorEngaged(false)
  87. t[i].setFluidFlowRateMax(0)
  88. end
  89.  
  90.  
  91. mon.clear()
  92. mon.setTextScale(5)
  93. mon.setCursorPos(1,2)
  94. term.clear()
  95. term.setCursorPos(1,1)
  96. mon.setTextColor(colors.red)
  97. term.setTextColor(colors.red)
  98. mon.write("off")
  99. term.write("off")
  100.  
  101. while true do
  102. local procent = v.getEnergyStored()/v.getMaxEnergyStored()*100
  103. if procent <= reactorOn then
  104. mon.clear()
  105. mon.setCursorPos(1,2)
  106. term.clear()
  107. term.setCursorPos(1,1)
  108. mon.setTextColor(colors.green)
  109. term.setTextColor(colors.green)
  110. mon.write("on")
  111. term.write("on")
  112. for i = 0, reactorNumber-1 do
  113. r[i].setActive(true)
  114. end
  115. sleep(5)
  116. for i = 0, amountTurbines-1 do
  117. t[i].setActive(true)
  118. t[i].setInductorEngaged(true)
  119. t[i].setFluidFlowRateMax(steam)
  120. end
  121. elseif procent >= reactorOff then
  122. mon.clear()
  123. mon.setCursorPos(1,2)
  124. term.clear()
  125. term.setCursorPos(1,1)
  126. mon.setTextColor(colors.red)
  127. term.setTextColor(colors.red)
  128. mon.write("off")
  129. term.write("off")
  130. for i = 0, amountTurbines-1 do
  131. t[i].setInductorEngaged(false)
  132. t[i].setFluidFlowRateMax(0)
  133. end
  134. for j = 0, reactorNumber-1 do
  135. r[j].setActive(false)
  136. end
  137. end
  138.  
  139.  
  140. mon.setCursorPos(1,1)
  141. mon.setTextScale(5)
  142. mon.setTextColor(colors.blue)
  143. mon.write(math.floor(procent).."%")
  144.  
  145. sleep(1)
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement