Guest User

startup

a guest
Aug 8th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local reactor = peripheral.wrap("back")
  2.  
  3. -- Max level is fixed for all reactor sizes?
  4. local reactorMaxEnergyCapacity = 10000000
  5. local reactorStoredEnergy = 0
  6. local reactorStoredEnergyPercentage = 0
  7. while true do
  8.   -- Get the amount of RF stored in the reactor
  9.   reactorStoredEnergy = reactor.getEnergyStored()
  10.   reactorStoredEnergyPercentage = (reactorStoredEnergy/reactorMaxEnergyCapacity)*100
  11.   print("Energy level at: " .. reactorStoredEnergy .. " (" .. reactorStoredEnergyPercentage .. ")")
  12.  
  13.   -- If the reactor is active AND % of stored energy is 99 or above
  14.   if reactor.getActive() and reactorStoredEnergyPercentage >= 99 then
  15.     -- turn off the reactor
  16.     print("Turning reactor off")
  17.     reactor.setActive(false)
  18.   elseif not reactor.getActive() and reactorStoredEnergyPercentage < 99 then
  19.     -- otherwise IF the reactor is not active AND stored RF below 99%
  20.     -- tur it on
  21.     print("Turning reactor on")
  22.     reactor.setActive(true)
  23.   end
  24.  
  25.   -- Sleep for aproximately 20 ticks so we don't
  26.   -- Overload the server unnecessarily
  27.   os.sleep(1)
  28. end
Advertisement
Add Comment
Please, Sign In to add comment