SHARE
TWEET

Reactor Test 90%

DerMarten Apr 13th, 2019 (edited) 16 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Config
  2. -- Max RF Ammount
  3. local maxRF = 10000000
  4. -- Reactor Active Sleep
  5. local activeSleep = 2
  6. -------------------------
  7. shell.run("clear")
  8. print("Reactor OS")
  9. local reactor = peripheral.wrap('back')
  10.  
  11. if(reactor.getConnected() == false)then
  12.     os.reboot()
  13. end
  14.  
  15. function getEnergyAsPercent()
  16.     energy = reactor.getEnergyStored()
  17.     onePercent = maxRF / 100
  18.     percent = energy / onePercent
  19.     return percent
  20. end
  21.  
  22. function checkEnergy()
  23.     if(getEnergyAsPercent() < 40) then
  24.         reactor.setActive(true)
  25.         local test = true
  26.         print("Reactor wurde eigeschaltet")
  27.         os.sleep(2)
  28.         while(test) do
  29.             shell.run("clear")
  30.             write("RF Speicher(%) ")
  31.             print(getEnergyAsPercent())
  32.             if(getEnergyAsPercent() > 90) then
  33.                 test = false
  34.             end
  35.             os.sleep(0.1)
  36.         end
  37.         schalter = true
  38.         rfto = 0
  39.         while schalter do
  40.             rft = reactor.getEnergyProducedLastTick()
  41.             if rfto > rft then
  42.                 schalter = false
  43.             end
  44.             rfto = rft
  45.             os.sleep(0.1)
  46.         end
  47.         reactor.setActive(false)
  48.         print("Reactor wurde ausgeschaltet")
  49.     end    
  50. end
  51.  
  52. while true do
  53.     checkEnergy()
  54.     shell.run("clear")
  55.     print("Reactor OS")
  56.     write("RF Speicher(%) ")
  57.     print(getEnergyAsPercent())
  58.     os.sleep(0.1)
  59. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top