SHARE
TWEET

Big Reactors: Turbine

scadl Sep 20th, 2016 (edited) 74 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(0.9)
  14.             monitor = peripher
  15.         end
  16.         if (deviceType == "BigReactors-Turbine") 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)/1000000
  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)/1000000
  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() < 970000
  58. then
  59.     reactor.setActive(true)
  60. else
  61.     reactor.setActive(false)
  62. end
  63.  
  64. sleep(5)
  65.  
  66. end
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top