Guest User

Minecraft BigReactors Actively Cooled ComputerCraft Script

a guest
Jan 2nd, 2016
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. local reactor = peripheral.wrap("bottom")
  2. local turbine = peripheral.wrap("BigReactors-Turbine_0")
  3.  
  4. turn = 0
  5. seq = false
  6. lastDiff = 0
  7.  
  8. while true do  
  9.   rsLvl = rs.getAnalogInput("right")
  10.   if seq then print(rsLvl .. '.')
  11.   else print(rsLvl) end
  12.   seq = not seq
  13.  
  14.   active = reactor.getActive()
  15.   if rsLvl < 3 and not active then
  16.     reactor.setAllControlRodLevels(100)
  17.     reactor.setActive(true)
  18.   elseif rsLvl > 12 and active then
  19.     reactor.setActive(false)
  20.   end
  21.  
  22.   if active then
  23.     diff = turbine.getRotorSpeed() - 1800
  24.     if diff < -100 then
  25.       steam = reactor.getHotFluidProducedLastTick()
  26.       if steam < 780 then
  27.         crLvl = reactor.getControlRodLevel(turn)
  28.         reactor.setControlRodLevel(turn, crLvl - 1)
  29.         turn = turn + 1
  30.         turn = turn % 8
  31.       elseif steam > 800 then
  32.         turn = turn - 1
  33.         turn = turn % 8
  34.         crLvl = reactor.getControlRodLevel(turn)
  35.         reactor.setControlRodLevel(turn, crLvl + 1)
  36.       end
  37.     elseif diff < 0 then
  38.       if diff <= lastDiff then
  39.         crLvl = reactor.getControlRodLevel(turn)
  40.         reactor.setControlRodLevel(turn, crLvl - 1)
  41.         turn = turn + 1
  42.         turn = turn % 8
  43.       elseif diff > lastDiff + 2 then
  44.         turn = turn - 1
  45.         turn = turn % 8
  46.         crLvl = reactor.getControlRodLevel(turn)
  47.         reactor.setControlRodLevel(turn, crLvl + 1)
  48.       end
  49.     elseif diff > 0 then
  50.       if diff >= lastDiff then
  51.         turn = turn - 1
  52.         turn = turn % 8
  53.         crLvl = reactor.getControlRodLevel(turn)
  54.         reactor.setControlRodLevel(turn, crLvl + 1)
  55.       end
  56.     end
  57.    
  58.     lastDiff = diff
  59.   end
  60.  
  61.   sleep(1)
  62. end
Advertisement
Add Comment
Please, Sign In to add comment