Advertisement
BookerTheGeek

Untitled

Apr 22nd, 2023 (edited)
1,115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. -- BigReactor active cooled fuel rod controller
  2. -- By BookerTheGeek
  3.  
  4. -- Variables
  5. local reactor = peripheral.wrap("back")
  6. local run = true
  7. local maxSteam = "50000"
  8. local createdSteam = "0"
  9. local connectedTurbines = "4"
  10. local goalSteamCreationmin = "0"
  11. local goalSteamCreationMax = "0"
  12. local steamTurbineNeed = "2000"
  13. local controlRodLevel = "0"
  14.  
  15. -- The Goods
  16. while run == true do
  17.  
  18. -- Turn Reactor On if Off
  19. if reactor.getActive() ~= "true" then
  20.     reactor.setActive(true)
  21. end
  22.  
  23. -- How much Steam do we need per Tick
  24. goalSteamCreationMin = (connectedTurbines * steamTurbineNeed) * 1.0
  25. goalSteamCreationMax = (connectedTurbines * steamTurbineNeed) * 1.1
  26.  
  27. -- How much steam are we producing
  28. createdSteam = reactor.getHotFluidProducedLastTick()
  29.  
  30. -- Are we making steam?
  31. if createdSteam == 0 then reactor.setAllControlRodLevels(0) end
  32.  
  33. -- Increase steam production
  34. if createdSteam <= goalSteamCreationMin then
  35.     controlRodLevel = controlRodLevel - 1
  36.     if controlRodLevel <= 0 then controlRodLevel = 0 end
  37.     reactor.setAllControlRodLevels(controlRodLevel)
  38. end
  39.  
  40. -- Decrease steam production
  41. if createdSteam >= goalSteamCreationMax then
  42.     controlRodLevel = controlRodLevel + 1
  43.     if controlRodLevel >= 100 then controlRodLevel = 100 end
  44.     reactor.setAllControlRodLevels(controlRodLevel)
  45. end
  46.  
  47. -- Output Information
  48. term.clear()
  49. term.setCursorPos(1,1)
  50. print("Steam Produced:", createdSteam, "mb/t" )
  51. print("Rod Level: ", controlRodLevel)
  52.  
  53. -- Wait to run again
  54. sleep(10)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement