MyrddinE

ComputerCraft BigReactor (Active) automatic throttling

May 30th, 2014
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. -- Title: ComputerCraft BigReactor automatic throttling software for Active reactors.
  2. -- Author: MyrddinE
  3. --
  4. -- Throttles the reactor based on the level of hot fluid. Because the hot fluid buffer
  5. -- is small compared to the generation speed, it updates several times a second to
  6. -- maintain the proper temperature.
  7.  
  8. -- Update this to match your reactor's steam volume.
  9. maxSteam = 9800
  10.  
  11. -- Set this to the side your monitor is on, or blank for no monitor. If the monitor is
  12. -- connected via a wired modem, set this to the full name of the monitor.
  13. monitor = ''
  14. -- monitor = 'right'
  15.  
  16. -- Stick the computer right on the port. If the reactor is attached via a wired modem,
  17. -- change the wrap to the full name of the Reactor.
  18. reactor = peripheral.wrap('back')
  19.  
  20. -- Sets the monitor to a wrapped peripheral if you have one.
  21. if #monitor > 0 then
  22.   monitor = peripheral.wrap(monitor)
  23.   width,height = monitor.getSize()
  24.   monitor.setCursorPos(1,height)
  25. else
  26.   monitor = false
  27. end
  28.  
  29. -- Run forever.
  30. while true do
  31.   -- The important part of the loop is just three lines, very simple.
  32.   steam = reactor.getHotFluidAmount()
  33.   rod = math.ceil(100*steam/maxSteam)
  34.   reactor.setAllControlRodLevels(rod)
  35.  
  36.   -- Everything below just drives a scrolling monitor display.
  37.   if monitor then
  38.     temp = math.floor(reactor.getCasingTemperature()).."C"
  39.     monitor.scroll(2)
  40.     monitor.setCursorPos(1,height)
  41.     monitor.write(rod.."%")
  42.     monitor.scroll(1)
  43.     monitor.setCursorPos(1+width-#temp,height)
  44.     monitor.write(temp)
  45.   end
  46.  
  47.   -- Sleep for a moment.
  48.   sleep(.2)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment