Advertisement
soulgriever

Untitled

Oct 1st, 2022
1,138
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 1 0
  1. p = peripheral.wrap("back")  --Where is the reactor
  2. componentThreshhold = 0.9 --90% durability lost
  3. SteamCapacity = 40000 -- Steam Reactor's have an internal capacity of 50000
  4.  
  5. term.clear()
  6. term.setCursorPos(1,1)
  7. print("Starting up Reactor Manager")
  8. print("Please Wait...")
  9.  
  10. --Checks to see if the reactor has Steam Vents and measures enables the steam sanity check if true
  11. sanitySteam = 0
  12. for i=1,54 do
  13.     if p.getItem(i) then
  14.         if p.getItemMeta(i).displayName == "Steam Vent" or p.getItemMeta(i).displayName == "Reactor Steam Vent" or p.getItemMeta(i).displayName == "Overclocked Steam Vent" or p.getItemMeta(i).displayName == "Advanced Steam Vent" then
  15.             sanitySteam = sanitySteam + 1
  16.         end
  17.     end
  18. end
  19. if sanitySteam > 0 then
  20.     SteamReactor = 1
  21. else
  22.     SteamReactor = 0
  23. end
  24.  
  25. --Starts the reactor loop
  26. while true do
  27.     if rs.getAnalogInput("front") > 0 then  --Checks the front of the computer for a Redstone signal to enable the reactor
  28.         T = 0  --sets initial componentThreshhold bit
  29.         F = 0  --sets initial fuelPresent bit
  30.         for i=1,54 do  --inspects every component in an ic2 reactor or steam reactor and checks to see if the durability is below the desired componentThreshhold, throws a componentThreshhold bit if true allowing the reactor to cool down
  31.             if p.getItem(i) then
  32.                 if p.getItemMeta(i).name ~= "ic2:itemreactorrods" then
  33.                     if p.getItemMeta(i).durability then
  34.                         if p.getItemMeta(i).durability > componentThreshhold then
  35.                             T = T + 1
  36.                         end
  37.                     end
  38.                 else
  39.                     F = F + 1
  40.                 end
  41.             end
  42.         end
  43.         term.clear()
  44.         term.setCursorPos(1,1)
  45.         if SteamReactor > 0 then
  46.             for _,v in pairs (p.getTanks()) do
  47.                 if v then
  48.                     if v.amount then
  49.                         print(v.name..":"..v.amount.."/"..v.capacity)
  50.                         if v.name == "steam" then
  51.                             if v.amount > SteamCapacity then
  52.                                 T = T + 1
  53.                             end
  54.                         end
  55.                     else
  56.                         if v.name == nil and v.capacity == 50000 then --Written due to a bug with the steam reactor itself
  57.                             print("steam:0/50000")
  58.                         end
  59.                     end    
  60.                 end
  61.             end
  62.         end
  63.         if T > 0 then
  64.             rs.setAnalogOutput("back", 0)
  65.             rs.setAnalogOutput("left", 15) -- turns a lamp to the left on to show the reactor is off
  66.             rs.setAnalogOutput("right", 0)
  67.             print("Reactor:Sleep Cycle")
  68.             sleep(2)
  69.         else
  70.             if F == 0 then
  71.                 rs.setAnalogOutput("back", 0)
  72.                 rs.setAnalogOutput("left", 15) -- turns a lamp to the left on to show the reactor is off
  73.                 rs.setAnalogOutput("right", 0)
  74.                 print("Reactor:Out of Fuel")
  75.                 sleep(2)
  76.             else
  77.                 rs.setAnalogOutput("back", 15)  --turns the reactor on
  78.                 rs.setAnalogOutput("left", 0)
  79.                 rs.setAnalogOutput("right", 15)  --turns a lamp to the right on to show the reactor is on
  80.                 print("Reactor:On")
  81.             end
  82.         end
  83.  
  84.     else  -- Disables the reactor because the redstone signal in front of the computer is off
  85.         rs.setAnalogOutput("back", 0)
  86.         rs.setAnalogOutput("left", 9)
  87.         rs.setAnalogOutput("right", 0)
  88.         sleep(10)
  89.     end
  90. end
  91.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement