Kenanja

reactor control

Nov 29th, 2020 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. local reactor = peripheral.wrap("bottom")
  2. local max = 10000000
  3. local upper = 0.65
  4. local lower = 0.35
  5. local upperTotal = max * upper
  6. local lowerTotal = max * lower
  7. local iterations = 0
  8. while (true) do
  9.     local energy = reactor.getEnergyStored()
  10.     if energy > upperTotal then
  11.         reactor.setActive(false)
  12.     end
  13.     if energy < lowerTotal then
  14.         reactor.setActive(true)
  15.     end
  16.     if iterations % 60 == 0 then
  17.         print(string.format("Running for %d minutes", iterations/60))
  18.     end
  19.     sleep(1)
  20.     iterations = iterations + 1
  21. end
Advertisement
Add Comment
Please, Sign In to add comment