Advertisement
Alakazard12

NuclearCraft reactor

Jan 7th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. local reactor = component.ns_fusion_reactor
  2.  
  3.  
  4. local hit_threshold = false
  5.  
  6. local function check()
  7.     local efficiency = reactor.getEfficiency()
  8.     print("Efficiency: " .. tostring(efficiency))
  9.  
  10.     if reactor.isProcessing() then
  11.         if efficiency > 0.95 then
  12.             print("Deactivating")
  13.             reactor.deactivate()
  14.             hit_threshold = true
  15.         end
  16.     else
  17.         if hit_threshold then
  18.             if efficiency < 0.9 then
  19.                 print("Activating")
  20.                 reactor.activate()
  21.                 hit_threshold = false
  22.             end
  23.         end
  24.     end
  25. end
  26.  
  27.  
  28. local function start()
  29.     while true do
  30.         if reactor.isHotEnough() then
  31.             print("Starting")
  32.             reactor.activate()
  33.             return
  34.         end
  35.         os.sleep(1)
  36.     end
  37. end
  38.  
  39. start()
  40.  
  41. while true do
  42.     os.sleep(1)
  43.     check()
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement