SHARE
TWEET

Big Reactors: Regular Reactor [Optimized]

scadl Dec 18th, 2016 (edited) 35 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Simple Big Reactors Regular Reactor control: Power only if discahrged
  2.  
  3. while true do
  4.  
  5. local sides = {"left", "right", "top", "bottom", "front", "back"}
  6. local reactor, monitor
  7.  
  8. for i, side in pairs(sides) do
  9.     if (peripheral.isPresent(side)) then
  10.         local deviceType = peripheral.getType(side)
  11.         local peripher = peripheral.wrap(side)
  12.         if (deviceType == "monitor") then
  13.             peripher.setTextScale(1.5)
  14.             monitor = peripher
  15.         end
  16.         if (deviceType == "BigReactors-Reactor") then
  17.             reactor = peripher
  18.             --print(reactor.getEnergyStored())
  19.         end
  20.         --print("Debug: side: '"..side.."', device: '"..deviceType.."'")
  21.     end
  22. end
  23.  
  24. monitor.clear()
  25. monitor.setCursorPos(1, 1)
  26. monitor.write('Reactor:')
  27. monitor.setCursorPos(1, 2)
  28. monitor.write('--------')
  29. monitor.setCursorPos(1,3)
  30. monitor.write('STATE:'..tostring(reactor.getActive()))
  31.  
  32. monitor.setCursorPos(1,5)
  33. local chprc = (reactor.getEnergyStored()*100)/10000000
  34. monitor.write('CHARGE:'..math.ceil(chprc).."%")
  35. monitor.setCursorPos(1,6)
  36. monitor.write(math.ceil(reactor.getEnergyStored()).." RF")
  37.  
  38. term.clear()
  39. term.setCursorPos(1, 1)
  40. term.write('Reactor:')
  41. term.setCursorPos(1, 2)
  42. term.write('--------')
  43. term.setCursorPos(1,3)
  44. term.write('STATE:'..tostring(reactor.getActive()))
  45.  
  46. term.setCursorPos(1,5)
  47. local chprc = (reactor.getEnergyStored()*100)/10000000
  48. term.write('CHARGE:'..math.ceil(chprc).."%")
  49. term.setCursorPos(1,6)
  50. term.write('CHARGE:'..math.ceil(reactor.getEnergyStored()).." RF")
  51.  
  52. term.setCursorPos(1,8)
  53. term.write("Press Ctrl+T")
  54. term.setCursorPos(1,9)
  55. term.write("to stop script")
  56.  
  57. if reactor.getEnergyStored() < 2000000
  58. then
  59.     reactor.setActive(true)
  60. end
  61. if reactor.getEnergyStored() > 8500000
  62. then
  63.     reactor.setActive(false)
  64. end
  65.  
  66. sleep(5)
  67.  
  68. 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