Advertisement
MigasRocha

"WasteBarrel Network" %Counter/ Computer ID:49

Dec 26th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | Gaming | 0 0
  1. local peripherals = peripheral.getNames()
  2. local length = #peripherals
  3. local singlecapacity = peripheral.wrap("radioactiveWasteBarrel_8").getCapacity()
  4. local totalstored = 0
  5. modem = peripheral.wrap("right")
  6.  
  7. modem.open(7)
  8.  
  9. while true do
  10.  
  11.     for _, name in ipairs(peripherals) do
  12.         if name ~= "back" then
  13.             if name ~= "right" then  
  14.             totalstored = 0 + peripheral.wrap(name).getStored().amount
  15.             end
  16.         end
  17.    
  18.     end
  19.  
  20.  
  21.     if totalstored >= singlecapacity*(length-2) then          
  22.             modem.transmit(7,7,"SCRAM")          
  23.             term.clear()
  24.             term.setCursorPos(1,1)
  25.             term.setTextColor(colors.red)
  26.             print("Danger")
  27.             term.setCursorPos(1,2)
  28.             print("Info:".. totalstored .."/"..singlecapacity*(length-2).." of "..length-2 .." barrels" )
  29.             term.setCursorPos(1,3)
  30.             print("PercentageTotalStored", string.format("%.2f",(totalstored * 100) / (singlecapacity*(length-2))).."%")
  31.     else
  32.         term.clear()
  33.         term.setCursorPos(1,1)
  34.             term.setTextColor(colors.lime)
  35.             print("Safe")
  36.             term.setCursorPos(1,2)
  37.             print("Info:".. totalstored .."/"..singlecapacity*(length-2).." of "..length-2 .." barrels" )
  38.             term.setCursorPos(1,3)
  39.             print("PercentageTotalStored", string.format("%.5f",(totalstored * 100) / (singlecapacity*(length-2))).."%")
  40.        
  41.     end
  42.  
  43.     sleep(1)
  44.  
  45. end
  46.  
  47.  
  48.            
  49.  
  50.  
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement