Advertisement
koriar

shutdown

Jan 23rd, 2021 (edited)
1,430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. fine = true
  2.  
  3. targetOutput = 500000
  4. minShieldPer = 30
  5.  
  6. reac = peripheral.wrap("back")
  7. local inRate
  8.  
  9. outGate = peripheral.wrap("right")
  10.  
  11. monitor = peripheral.wrap("top")
  12.  
  13. if monitor == null then
  14.     monitor = periphSearch("monitor")
  15. end
  16.  
  17. if monitor ~= null then
  18.     term.redirect(monitor)
  19. end
  20.  
  21. if peripheral.wrap("top") then
  22.     monitor = peripheral.wrap("top")
  23.  
  24. end
  25.  
  26. function periphSearch(type)
  27.    local names = peripheral.getNames()
  28.    local i, name
  29.    for i, name in pairs(names) do
  30.       if peripheral.getType(name) == type and name ~= "right" then
  31.          return peripheral.wrap(name)
  32.       end
  33.    end
  34.    return null
  35. end
  36.  
  37. inGate = periphSearch("flux_gate")
  38.  
  39. targetOutput = outGate.getSignalLowFlow()
  40. minShieldPer = 30
  41.  
  42.  
  43. --start
  44.  
  45. term.clear()
  46. print("Shutting down reactor")
  47.  
  48. outGate.setSignalLowFlow(0)
  49. reac.stopReactor()
  50.  
  51. while fine == true do
  52.     sleep(1)
  53.     term.clear()
  54.     local rInfo = reac.getReactorInfo()
  55.     local shieldPer = math.ceil(rInfo.fieldStrength / rInfo.maxFieldStrength * 10000) * .01
  56.  
  57.     print("Temperature: ",rInfo.temperature)
  58.     print("Shield Percent: ",shieldPer)
  59.     print("Fuel percentage: ",100 - math.ceil((rInfo.fuelConversion / rInfo.maxFuelConversion * 100)))
  60.  
  61.     inRate = rInfo.fieldDrainRate / (1 - (targetOutput/1000000))
  62.     --inRate = rInfo.fieldDrainRate / (1 - (targetOutput/100))
  63.     print("Input gate set at ",inRate)
  64.     inGate.setSignalLowFlow(inRate)
  65. end
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement