Advertisement
mrkarp

steamcontrol

Mar 12th, 2021
1,157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1.  
  2.  
  3. local periList = peripheral.getNames()
  4.  
  5. -- Main Function
  6. function main()
  7.     while true do
  8.         if reactor.getHotFluidAmount() < (reactor.getHotFluidAmountMax() - 5) then
  9.             reactor.setActive(true)
  10.         else
  11.             reactor.setActive(false)
  12.         end
  13.     sleep(5)
  14.     end
  15. end
  16.  
  17. function tablelength(T)
  18.   local count = 0
  19.   for _ in pairs(T) do count = count + 1 end
  20.   return count
  21. end
  22.  
  23. function restart()
  24.     main()
  25. end
  26.  
  27. -- Startup
  28. print('Steam Reactor Control Engaged. Incoming parameters...')
  29. for i = 1, #periList do
  30.     --print("I have a "..peripheral.getType(periList[i]).." attached as \""..periList[i].."\".")
  31.     if peripheral.getType(periList[i]) == "BigReactors-Reactor" then
  32.         reactor =  peripheral.wrap(periList[i])
  33.         controlRodNumber = tablelength(reactor.getControlRodsLevels())
  34.         print("Wrapped Reactor: "..periList[i])
  35.     end
  36. end
  37.  
  38. -- Reactor Connection Checl
  39. if reactor then
  40.  main()
  41. else
  42.     print("reactor not connected")
  43. end
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement