Plazter

Reactor[Big Reactors]

Apr 12th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. reactor = {peripheral.find("BigReactors-Reactor")}
  2. bank = {peripheral.find("tile_blockcapacitorbank_name")}
  3. mon = peripheral.wrap("right")
  4. turbine = {peripheral.find("BigReactors-Turbine")}
  5. local function keepRPM()
  6.   for i = 1,#turbine do
  7.     if turbine[i].getRotorSpeed() < 1830 then
  8.       for i =1,#reactor do
  9.         reactor[i].setActive(true)
  10.       end
  11.     elseif turbine[i].getRotorSpeed() > 1800 then
  12.       for i = 1,#reactor do
  13.         reactor[i].setActive(false)
  14.       end
  15.     end
  16.   end
  17. end
  18.  
  19.  
  20. local function waste()
  21.   for i= 1,#reactor do
  22.     print("Reactor "..i.." Curr. Waste     : "..reactor[i].getWasteAmount().." mB")
  23.   end
  24. end
  25. local function fuel()
  26.   for i= 1,#reactor do
  27.     print("Reactor "..i.." Curr. fuel      : "..reactor[i].getFuelAmount().." mB")
  28.   end
  29. end
  30.  
  31. local function steamOutput()
  32.   for i=1,#reactor do
  33.     print("Reactor "..i.." Steam produced  : "..reactor[i].getHotFluidProducedLastTick().." mB")
  34.   end
  35. end
  36.  
  37. local function bkInfo()
  38.   --term.setCursorPos(1,10)
  39.     print("Currently Stored: ".. bank[1].getEnergyStored().." / ".. bank[1].getMaxEnergyStored())
  40. end
  41.  
  42. local function onOff()
  43.   if bank[1].getEnergyStored() > bank[1].getMaxEnergyStored()*0.8 then
  44.     for i = 1,#reactor do
  45.     reactor[i].setActive(false)
  46.     keepRPM()
  47.     end--for
  48.   elseif bank[1].getEnergyStored() < bank[1].getMaxEnergyStored()*0.5 then
  49.     for i = 1,#reactor do
  50.     reactor[i].setActive(true)
  51.     end--for
  52.   end--if
  53. end--func
  54.  
  55. local function isOn()
  56.   for i = 1,#reactor do
  57.     print("Reactor "..i.." Currently on/off: ".. tostring(reactor[i].getActive()))
  58.   end
  59. end
  60.  
  61. term.redirect(mon)
  62. for i = 1,#reactor do
  63.   reactor[i].setActive(true)
  64. end
  65. while true do
  66. term.setBackgroundColor(colors.blue)
  67. onOff()
  68. term.clear()
  69. term.setCursorPos(1,1)
  70. print("Reactor info")
  71. isOn()
  72. fuel()
  73. waste()
  74. steamOutput()
  75. bkInfo()
  76. sleep(.5)
  77. end
  78. term.native()
Add Comment
Please, Sign In to add comment