Advertisement
cyber_Ahn

Ficsit-Networks-Storage_Monitor

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