Advertisement
cyber_Ahn

Ficsit-Networks-Storage_Monitor

May 14th, 2022
1,213
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ----------------------var------------------------------------------
  2. Name = "Storage_PC"
  3. screen_id = "641B9F994DBF6D0CD7C95FA072E50089"
  4. ----------------------get-hardware---------------------------------
  5. local NetworkCard = computer.getPCIDevices(findClass("NetworkCard"))[1]
  6.  
  7. local InternetCard = computer.getPCIDevices(findClass("FINInternetCard"))[1]
  8.  
  9. local gpu = computer.getPCIDevices(findClass("GPUT1"))[1]
  10. if not gpu then
  11.  error("No GPU T1 found!")
  12. end
  13.  
  14. local screen = computer.getPCIDevices(findClass("FINComputerScreen"))[1]
  15. if not screen then
  16.  local comp_b=""
  17.  local comp = component.findComponent(findClass("Screen"))
  18.  for i=1, #comp do
  19.   if comp[i] == screen_id then
  20.    comp_b = comp[i]
  21.   end
  22.  end
  23.  screen = component.proxy(comp_b)
  24. end
  25. gpu:bindScreen(screen)
  26. gpu:setSize(120,40)
  27. w,h = gpu:getSize()
  28. gpu:setSize(w,h)
  29. gpu:fill(0,0,w,h," ")
  30. gpu:flush()
  31. gpu:setText(0,0,"Start Terminal......")
  32. gpu:setText(0,1,"Please wait......")
  33. gpu:flush()
  34. event.pull(10)
  35. gpu:fill(0,0,w,h," ")
  36. gpu:flush()
  37.  
  38.  
  39. local storage = component.proxy(component.findComponent("Storage"))
  40. local fluid = component.proxy(component.findComponent("F_Storage"))
  41.  
  42. function draw_frame(x,y,le,dire)
  43.  for i=0, le do
  44.   if dire == "right" then
  45.    gpu:setText(x+i,y, "-")
  46.   end
  47.   if dire == "down" then
  48.    gpu:setText(x,y+i, "|")
  49.   end
  50.  end
  51. end
  52.  
  53. function round(x)
  54.   return math.floor(x + 0.5)
  55. end
  56.  
  57. function main_prog()
  58.  while true do
  59.   lines = 0
  60.   linesB = 0
  61.   gpu:fill(0,0,w,h," ")
  62.   gpu:flush()
  63.   gpu:setForeground(1,1,1,1)
  64.   gpu:setSize(w,h)
  65.   gpu:setText(w/3,0, "Storage Monitor V1.0")
  66.   for i=1, #storage do
  67.    lines = i
  68.    inv = storage[i]:getInventories()[1]
  69.    inv:sort()
  70.    amount = inv.itemCount
  71.    itemName = "Empty"
  72.    max = 0
  73.    if amount > 1 then
  74.     max = inv:getStack(0).count * inv.size
  75.     itemName = inv:getStack(0).item.type.name
  76.    end
  77.    gpu:setText(2,i+1, "Container_"..i)
  78.    gpu:setText(16,i+1, itemName)
  79.    if (max/2) > amount then
  80.     gpu:setForeground(1,0,0,1)
  81.    end
  82.    if (max/2) < amount then
  83.     gpu:setForeground(1,1,0,1)
  84.    end
  85.    if amount == max then
  86.     gpu:setForeground(0,1,0,1)
  87.    end
  88.    if amount == 0 then
  89.     gpu:setForeground(1,0,0,1)
  90.    end
  91.    gpu:setText(47,i+1, amount.."/"..max)
  92.    gpu:setForeground(1,1,1,1)  
  93.   end
  94.   for i=1, #fluid do
  95.    linesB = i
  96.    itemName = "Empty"
  97.    isF = fluid[i].fluidContent
  98.    maxF = fluid[i].maxFluidContent
  99.    if isF > 1 then
  100.     itemName = fluid[i]:getFluidType().name
  101.    end
  102.    gpu:setText(70,i+1, "Fluid_"..i)
  103.    gpu:setText(79,i+1, itemName)
  104.    if (maxF/2) > isF then
  105.     gpu:setForeground(1,0,0,1)
  106.    end
  107.    if (maxF/2) < isF then
  108.     gpu:setForeground(1,1,0,1)
  109.    end
  110.    if isF == maxF then
  111.     gpu:setForeground(0,1,0,1)
  112.    end
  113.    if isF == 0 then
  114.     gpu:setForeground(1,0,0,1)
  115.    end
  116.    if isF > maxF then
  117.     gpu:setForeground(0,1,0,1)
  118.    end
  119.    gpu:setText(103,i+1, round(isF).."/"..round(maxF))
  120.    gpu:setForeground(1,1,1,1)
  121.   end
  122.   draw_frame(0,1,119,"right")
  123.   draw_frame(0,2,lines-1,"down")
  124.   draw_frame(119,2,lines-1,"down")
  125.   draw_frame(65,2,lines-1,"down")
  126.   draw_frame(66,linesB+2,52,"right")
  127.   draw_frame(0,lines+2,119,"right")
  128.   gpu:flush()
  129.   event.pull(10)
  130.  end
  131. end
  132. main_prog()
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement