Advertisement
Guest User

controller_turbines

a guest
Dec 2nd, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.35 KB | None | 0 0
  1. -- this program is designed to control the output
  2. -- steam proceduce by a really big reactor.
  3. -- local variables
  4.  
  5. local i=0
  6. local iTurbines = 0
  7. local mon = peripheral.wrap("monitor_8")
  8. local reactor = peripheral.wrap("BigReactors-Reactor_7")
  9. local turbines = {peripheral.find("BigReactors-Turbine")}
  10. local iNumRods = 0
  11. local iNumFuelAmount = 0
  12. local iFuelTemp = 0
  13. local iCasingTemp = 0
  14. local iHotAmount = 0
  15. local iCoolantAmount = 0
  16. local iVentOff = 0
  17. local iReactorHeight = 0
  18.  
  19. local vRSside = "right"  -- this is the side of the computer the redstone single is on
  20.  
  21. local bVentSteam = true;
  22.  
  23. function WL( color, text)
  24.   i = i + 1
  25.   mon.setCursorPos(1,i)
  26.   mon.setTextColor(color)
  27.   mon.write(text)
  28. end -- WL Write Line
  29.  
  30. local function FormatString( iLength, text)
  31.   local padding = '                                  '
  32.   local text_len = string.len(text)
  33.   local len_diff = 0
  34.   local new_text = ' '
  35.  
  36.   len_diff = iLength - text_len
  37.  
  38.   if len_diff < 1 then
  39.      len_diff = 0
  40.   end -- check for negative values
  41.  
  42.   new_text = string.sub(padding,1,len_diff) .. text
  43.  
  44.   return new_text    
  45.                  
  46. end -- FormatString
  47.  
  48. function RefreshValues()
  49.  
  50.   iNumRods = reactor.getNumberOfControlRods()
  51.   iNumFuelAmount = reactor.getFuelAmount()
  52.   iHotAmount = reactor.getHotFluidAmount()
  53.   iCoolantAmount = reactor.getCoolantAmount()
  54.  
  55. end -- RefreshValues Variables
  56.  
  57. function BoolStr( bBool)
  58.  
  59.   local temp = "False"
  60.  
  61.   if bBool then
  62.     temp = "True"
  63.   end
  64.   return temp
  65. end -- Bool to String
  66.  
  67. function SetTurbineVentControl( )
  68.  
  69.   for x,y in ipairs( turbines) do
  70.     y.setVentOverflow()
  71.   end -- turbine loop
  72.  
  73. end -- SetTurbineVentControl
  74.  
  75. function GetHeight()
  76.   local min_x = 0
  77.   local min_y = 0
  78.   local min_z = 0
  79.   local max_x = 0
  80.   local max_y = 0
  81.   local max_z = 0
  82.    
  83.   iReactorHeight = 0
  84.  
  85.   min_x, min_y, min_z = reactor.getMinimumCoordinate()
  86.   max_x, max_y, max_z = reactor.getMaximumCoordinate()
  87.  
  88.   iReactorHeight = max_y - min_y - 1
  89.  
  90.  
  91. end -- Get Reactor Height
  92.  
  93. -- -------------------------------------------
  94. -- - Main Loop                               -
  95. -- -------------------------------------------
  96. rs.setOutput(vRSside, bVentSteam)
  97. SetTurbineVentControl()
  98. GetHeight()
  99.  
  100. while true do
  101.    RefreshValues()
  102.    mon.clear()
  103.    i = 0
  104.    iTurbines = 0
  105.    iFuelTemp = reactor.getFuelTemperature()
  106.    iCasingTemp = reactor.getCasingTemperature()
  107.    iTurbines = #turbines
  108.    
  109.  
  110.    WL(colors.white, "Number of Turbines: " .. iTurbines)
  111.    WL(colors.white, "Number of Rods    : " .. iNumRods )      
  112.    WL(colors.white, "Reactor Height    : " .. iReactorHeight )
  113.    WL(colors.white, "Amount of Fuel    : " .. iNumFuelAmount)
  114.    WL(colors.white, "Casing Heat       : " .. iCasingTemp )
  115.    WL(colors.white, "Core Heat         : " .. iFuelTemp )
  116.    WL(colors.white, "Steam Out /T      : " .. math.floor(reactor.getEnergyProducedLastTick()) )
  117.    WL(colors.white, "Coolant Reserve   : " .. iHotAmount )
  118.    WL(colors.white, "Steam Reserve     : " .. iCoolantAmount )
  119.    WL(colors.white, "Vent Steam (trash): " .. BoolStr(bVentSteam) .. " -- Times On: " .. iVentOff )
  120.  
  121.    if iFuelTemp > 1600 then
  122.      bVentSteam = true;
  123.      iVentOff = iVentOff + 1
  124.    else
  125.      bVentSteam = false;
  126.    end -- check steam level
  127.    
  128.    rs.setOutput( vRSside, bVentSteam);
  129.    sleep(.5)
  130. end -- while true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement