Advertisement
Guest User

startup

a guest
Jun 20th, 2021
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.22 KB | None | 0 0
  1. -- modified to work with draconic rf storage (trying to determine actual 'gain' from reactor)
  2. --local stabilizer = peripheral.wrap("right")
  3.  
  4. local storage = peripheral.find("draconic_rf_storage")
  5. local monitor = peripheral.wrap("bottom")
  6. local    core = peripheral.wrap("right")
  7. local fluxgate = peripheral.find("flux_gate")
  8. local powerstate = 0
  9. term.redirect(monitor)
  10. local x=0
  11. local y=0
  12. local fieldStrengthPercent=0
  13. local lastFieldStrengthPercent
  14. local energySaturationPercent=0
  15. local lastEnergySaturationPercent=0 -- last energy saturation
  16. local ecrft=0 -- energy core rf per tick
  17.  
  18. fluxgate.setOverrideEnabled(true)
  19.  
  20. while true do
  21.  
  22. monitor.clear()
  23. monitor.setCursorPos(1,1)
  24. monitor.setTextColor(colors.white)
  25. --for key,value in pairs(storage) do
  26. --print("key: "..key..", value: "..value)
  27. --end
  28.  
  29. --for _,method in pairs(storage) do
  30. y=x
  31. x=storage.getEnergyStored()
  32. --end
  33. local stab = core.getReactorInfo()
  34.  
  35. --for _, method in pairs(stabilizer) do
  36. --print(method)
  37. --end
  38. powerstate=stab.status
  39. -- print("              status: "
  40. monitor.setCursorPos(15,1)
  41. print("status:")
  42.  
  43. if powerstate=="online" then
  44.   monitor.setTextColor(colors.green)
  45. else
  46.   monitor.setTextColor(colors.red)
  47. end
  48. monitor.setCursorPos(23,1)
  49. print(powerstate)
  50. monitor.setTextColor(colors.white)
  51. -- print("              status: "..stab.status)
  52. print("      generationRate: "..stab.generationRate.." RF/t")
  53. print("         temperature: "..stab.temperature)
  54. print("       fieldStrength: "..stab.fieldStrength)
  55. print("    maxFieldStrength: "..stab.maxFieldStrength)
  56. print("      fieldDrainRate: "..stab.fieldDrainRate)
  57. print("Fuel Conversion Rate: "..stab.fuelConversionRate.." nb/t")
  58. print("   maxFuelConversion: "..stab.maxFuelConversion)
  59. local fuelConversionPercent=stab.fuelConversion*100/stab.maxFuelConversion
  60. print("      fuelConversion: "..stab.fuelConversion.."("..math.floor(fuelConversionPercent).."%)")
  61. lastEnergySaturationPercent=energySaturationPercent
  62. energySaturationPercent=stab.energySaturation*100/stab.maxEnergySaturation
  63. print("    energySaturation: "..stab.energySaturation.."("..math.floor(energySaturationPercent).."%) "..energySaturationPercent-lastEnergySaturationPercent)
  64. print(" maxEnergySaturation: "..stab.maxEnergySaturation)
  65. print("       fluxgate flow: "..fluxgate.getFlow())
  66. lastFieldStrengthPercent=fieldStrengthPercent
  67. fieldStrengthPercent=stab.fieldStrength*100/stab.maxFieldStrength
  68.  
  69. print(" Cont. fieldStrength: "..math.floor(fieldStrengthPercent).."%".."("..fieldStrengthPercent-fieldStrengthPercent..")")
  70. if (lastEnergySaturationPercent<energySaturationPercent) then
  71.   print("++++ Correcting")
  72. elseif (lastEnergySaturationPercent>energySaturationPercent) then
  73.   print("!!!! Degrading")
  74. end
  75. -- print(" --- ")
  76. print(" Energy Core Storage: "..x)
  77. ecrft=((((x-y)/1000/1000)/2)/20) -- there are 20 ticks in a second so you /20 not multiple dufus
  78. print("    Energy Core RF/t: "..ecrft.."MRF/t"..", "..(x*100/2140000000000).."%")
  79.  
  80. if (fieldStrengthPercent<51 or energySaturationPercent<51) then
  81. -- if it's < than some kill switch probably have it scram the reactor
  82.   redstone.setOutput("top", not redstone.getOutput("top"))
  83.   redstone.setOutput("back",false)
  84. --  move correcting/degrading message inside this loop
  85. -- its not really relevant when it's 'safe' over 51%
  86. end
  87. if (fieldStrengthPercent>51 and energySaturationPercent>51) then
  88.   redstone.setOutput("top",false)
  89.   redstone.setOutput("back",true) -- redstone.getOutput("top"))
  90. end
  91. -- Energy dump, if core>25% then
  92. -- and if net gain >100MRf/t
  93. -- (and less than say 1000 to prevent initialization issues)
  94. -- set fluxgate low flow to core net gain
  95. --if ecrft>100 and ecrft<1000 then
  96.   if (x*100/2141200000000)>70 then
  97. --    fluxgate.setSignalLowFlow=ecrft
  98. --    setFlowOverride=ecrft
  99. --    print("Set flow to "..ecrft)
  100. --if ecrft>100 then
  101.   -- not sure why but 1000 only seemed to reduce 'gain' by ~200k
  102. --    fluxgate.setFlowOverride(ecrft*4000)
  103.     fluxgate.setFlowOverride(stab.generationRate-(stab.fieldDrainRate*2))
  104. --  end
  105. --    fluxgate.setSignalLowFlow=ecrft*1000
  106. --    fluxgate.setOverrideEnabled(true)
  107.   else
  108.     fluxgate.setFlowOverride(500000)
  109.   end
  110. --  print("debug: ecrft="..ecrft..", %"..x*100/2141200000000)
  111. --  end
  112. --end
  113.  
  114. sleep(2)
  115. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement