Advertisement
ame824

Reactor-Steam-Control

Sep 25th, 2022 (edited)
1,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | Gaming | 0 0
  1. local waitTime = 0.5
  2.  
  3. local reactor = peripheral.find("BiggerReactors_Reactor")
  4. local reactorMaxCoolant = reactor.coolantTank().capacity()
  5.  
  6. function getReactorFluidPercent()  
  7.     local actualWaterLevel = reactor.coolantTank().coldFluidAmount()
  8.     local percent = ( 100 / reactorMaxCoolant ) * actualWaterLevel
  9.     return percent
  10. end
  11.  
  12. function setRodLevel(percent)
  13.     local reactorRodNum = reactor.controlRodCount()
  14.     local rodPercent = 100-percent
  15.     for count = 0, reactorRodNum-1, 1 do
  16.         reactor.getControlRod(count).setLevel(rodPercent)
  17.     end
  18. end
  19.  
  20. function main()
  21.     while true do
  22.         local percent = getReactorFluidPercent()
  23.         setRodLevel(percent)
  24.         print("Debug: "..percent)
  25.         os.sleep(waitTime)
  26.     end
  27. end
  28.  
  29. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement