Advertisement
Ubidibity

JustReactorandCapacitor

Aug 24th, 2015 (edited)
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- credits to:
  2. -- Clone of JSfPTB51, remove the reactor for earlier game reactor/capacitor pairing.
  3. -- note however, in a really eary game where gold isn't abundant you can use regular monitors
  4. -- but you have to remark out the color lines, in either case a regular computer is fine.
  5. -- https://youtu.be/sHN-KQKUkaY
  6. -- As a base, modified for my turbine/enderio capacitor bank
  7. -- when you connect the periphrials, check the log, these values should match what's in the code, if not
  8. -- you need to change it...
  9. -- [19:07:21] [Client thread/INFO]: [CHAT] Peripheral "computer_42" connected to network
  10. -- [19:07:24] [Client thread/INFO]: [CHAT] Peripheral "monitor_21" connected to network
  11. -- [19:07:27] [Client thread/INFO]: [CHAT] Peripheral "BigReactors-Reactor_18" connected to network
  12. -- [22:15:51] [Client thread/INFO]: [CHAT] Peripheral "tile_blockcapacitorbank_name_8" connected to network
  13.  
  14. -- basic setup for this...
  15. -- reactor has a computer port
  16. -- there are four modems connected with network cable (per above don't forget to click connect them and note their numbers, and
  17. -- update the definitions below)
  18. -- a modem goes on computer port, on any side of the computer, and one on the multi block monitor bank, and one on the capacitor(s)
  19. -- I use a 2x2 monitor, though if you add more lines (1,8) for example, and run off the bottom you can keep stacking
  20. -- them down x2 or you can make output wider by going 3x2, etc, it doesn't care it's treated as a single monitor so long as it's
  21. -- a square or a rectangle (it doesn't do tetris pieces, at that point you'd use different monitor wrappers like mon1 and mon2)
  22. -- This isn't complex, but that's what I like about it.  It doesn't auto configure or do anything fancy, it just monitors
  23. -- what you tell it, and turns the reactor on and off to conserve fuel...
  24. -- for an api reference, I use and recommend:
  25. -- http://ftbwiki.org/Reactor_Computer_Port
  26. -- http://ftbwiki.org/Turbine_Computer_Port
  27.  
  28. -- I've further decided to stop treating the reactor like a reactor, instead of messing with the control rods the
  29. -- turbine works best with the rods set to 20%, so I'll just leave it at 20%, and shut it off when it's full.
  30.  
  31. while true do
  32.   local reactor1 = peripheral.wrap("BigReactors-Reactor_12")
  33.   local capacitor = peripheral.wrap("tile_blockcapacitorbank_name08")
  34.   local mon = peripheral.wrap("monitor_18")
  35.  
  36.   -- basic capacitor low, 10k of 100k capacity ( single basic capacitor )
  37.   local low = 10000
  38.   -- adjust this to about 80% of "full" whatever that is (depends on how many capacitors you have)
  39.   local high = 800000
  40.   -- adjust this to whatever max is
  41.   local full = 1000000
  42.  
  43.   if capacitor.getEnergyStored() <= low then
  44.     reactor1.setAllControlRodLevels(20)
  45.     if reactor1.getActive() == false then
  46.       reactor1.setActive(true)
  47.     end
  48.   end
  49.  
  50.   if reactor1.getEnergyStored() == full then
  51.      reactor1.setActive(false)
  52.   else
  53.     if reactor1.getEnergyStored() >= high then
  54.       reactor1.setAllControlRodLevels(90)
  55.       reactor1.setActive(true)
  56.     end
  57.   end
  58.  
  59.   mon.clear()
  60.  
  61.   mon.setCursorPos(1,1)
  62.   mon.setTextColor(colors.white)
  63.   mon.write("Active: ")
  64.   mon.setTextColor(colors.lime)
  65.   mon.write(reactor1.getActive())
  66.    
  67.   mon.setCursorPos(1,2)
  68.   mon.setTextColor(colors.white)
  69.   mon.write("Casing Heat: ")
  70.   mon.setTextColor(colors.lime)
  71.   mon.write(math.floor(reactor1.getCasingTemperature()))
  72.  
  73.   mon.setCursorPos(1,3)
  74.   mon.setTextColor(colors.white)
  75.   mon.write("Fuel Heat: ")
  76.   mon.setTextColor(colors.lime)
  77.   mon.write(math.floor(reactor1.getFuelTemperature()))
  78.  
  79.   mon.setCursorPos(1,6)
  80.   mon.setTextColor(colors.white)
  81.   mon.write("RF: ")  
  82.   mon.setTextColor(colors.lime)
  83.   mon.write(math.floor(reactor1.getEnergyStored()))
  84.  
  85.   mon.setCursorPos(1,7)
  86.   mon.setTextColor(colors.white)
  87.   mon.write("C-RF: ")
  88.   mon.setTextColor(colors.lime)
  89.   mon.write(math.floor(capacitor.getEnergyStored()))
  90.  
  91.   sleep(10)
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement