Advertisement
Guest User

turbine_control

a guest
May 21st, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. tur1 = peripheral.wrap("BigReactors-Turbine_3")
  2. tur2 = peripheral.wrap("BigReactors-Turbine_4")
  3. tur3 = peripheral.wrap("BigReactors-Turbine_5")
  4. tur4 = peripheral.wrap("BigReactors-Turbine_6")
  5.  
  6. rednet.open("bottom")
  7.  
  8. while true do
  9.  
  10. term.clear()
  11. term.setCursorPos(1,1)
  12.  
  13. TB1statt = tostring(tur1.getActive())
  14.  
  15. if TB1statt == "true" then TB1stat = "active"
  16. else TB1stat = "offline"
  17. end
  18.  
  19. TB2statt = tostring(tur2.getActive())
  20.  
  21. if TB2statt == "true" then TB2stat = "active"
  22. else TB2stat = "offline"
  23. end
  24.  
  25.  
  26. TB3statt = tostring(tur3.getActive())
  27.  
  28. if TB3statt == "true" then TB3stat = "active"
  29. else TB3stat = "offline"
  30. end
  31.  
  32. TB4statt = tostring(tur4.getActive())
  33.  
  34. if TB4statt == "true" then TB4stat = "active"
  35. else TB4stat = "offline"
  36. end
  37.  
  38.  
  39. print("turbine 1 status: "..TB1stat)
  40. print("turbine 2 status: "..TB4stat)
  41. print("turbine 3 status: "..TB2stat)
  42. print("turbine 4 status: "..TB3stat)
  43. print("")
  44. tb1EN = tur1.getEnergyStored()
  45. tb2EN = tur2.getEnergyStored()
  46. tb3EN = tur3.getEnergyStored()
  47. tb4EN = tur4.getEnergyStored()
  48.  
  49. tb1pp = tb1EN / 1000000*100
  50. tb2pp = tb2EN / 1000000*100
  51. tb3pp = tb3EN / 1000000*100
  52. tb4pp = tb4EN / 1000000*100
  53.  
  54. tb1p = math.floor(tb1pp * 100)/100
  55. tb2p = math.floor(tb2pp * 100)/100
  56. tb3p = math.floor(tb3pp * 100)/100
  57. tb4p = math.floor(tb4pp * 100)/100
  58.  
  59. all = (tb1EN + tb2EN + tb3EN + tb4EN) /4
  60. allp = all /1000000 * 100
  61. allp = math.floor(allp *100)/100
  62.  
  63. print("turbine 1 energy: "..tb1EN.." => "..tb1p.."%")
  64. print("turbine 2 energy: "..tb4EN.." => "..tb4p.."%")
  65. print("turbine 3 energy: "..tb2EN.." => "..tb2p.."%")
  66. print("turbine 4 energy: "..tb3EN.." => "..tb3p.."%")
  67. print("")
  68. print("All turbine buffer % status: "..allp.."%")
  69.  
  70.  
  71. print("")
  72. print("")
  73. print("")
  74. print("Additional information:")
  75.  
  76. if (tb1p < 30) or (tb2p < 30) or (tb3p < 30) or (tb4p < 30) then
  77. redstone.setOutput("front",true)
  78. rednet.send(45,"RUN")
  79. print("Starting reactor and turbines due to one turbine is energy <30%")
  80. tur1.setActive(true)
  81. tur2.setActive(true)
  82. tur3.setActive(true)
  83. tur4.setActive(true)
  84. else
  85. print("No need to start reactor")
  86. end
  87.  
  88. if (allp > 95) then
  89. redstone.setOutput("front",false)
  90. rednet.send(45,"STOP")
  91. tur1.setActive(false)
  92. tur2.setActive(false)
  93. tur3.setActive(false)
  94. tur4.setActive(false)
  95. print("Stopping reactor and turbines due to energy > 95%")
  96. else
  97. print("No need to stop reactor")
  98. end
  99.  
  100.  
  101.  
  102. sleep(0.5)
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement