BlissSilence

Untitled

Dec 30th, 2024 (edited)
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. rs = peripheral.find("rsBridge")
  2. monitor = peripheral.find('monitor')
  3.  
  4. -- Redirects writes to monitor (if any)
  5. term.redirect(monitor)
  6.  
  7. w, h = monitor.getSize() -- Get monitor width and height
  8. boxWidth = 15 -- Width of each box
  9. boxHeight = 8 -- Height of each box (including border)
  10. boxesPerRow = math.floor(w / boxWidth)
  11. rows = math.floor(h / boxHeight)
  12.  
  13. -- Draws a box with a green outer edge
  14. function drawBox(x, y, width, height, innerColor, borderColor)
  15. -- Outer green border (1 pixel larger)
  16. paintutils.drawFilledBox(x, y, x + width, y + height, borderColor)
  17.  
  18. -- Inner light grey box (slightly smaller for border effect)
  19. paintutils.drawFilledBox(x + 1, y + 1, x + width - 1, y + height - 1, innerColor)
  20.  
  21. -- Optional black outline for sharpness
  22. paintutils.drawBox(x, y, x + width, y + height, colors.black)
  23. end
  24.  
  25. -- Prints text inside the box
  26. function printInBox(x, y, text, lineOffset)
  27. term.setCursorPos(x + 1, y + lineOffset)
  28. displayText = text
  29. if #displayText > boxWidth - 2 then
  30. displayText = string.sub(displayText, 1, boxWidth - 3) .. "..."
  31. end
  32. term.write(displayText)
  33. end
  34.  
  35. while true do
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. rsitems = rs.listItems()
  39.  
  40. -- Filter items with 1000+ count
  41. filteredItems = {}
  42. for _, item in pairs(rsitems) do
  43. if item.amount >= 1000 then
  44. table.insert(filteredItems, item)
  45. end
  46. end
  47.  
  48. -- Sort filtered items from largest to smallest
  49. table.sort(filteredItems, function(a, b)
  50. return a.amount > b.amount
  51. end)
  52.  
  53. -- Render items inside boxes
  54. for i, item in ipairs(filteredItems) do
  55. col = ((i - 1) % boxesPerRow) * boxWidth + 1
  56. row = math.floor((i - 1) / boxesPerRow) * boxHeight + 1
  57.  
  58. -- Break if exceeding screen space
  59. if row + boxHeight > h then
  60. break
  61. end
  62.  
  63. -- Draw box with outer green edge and light grey inner fill
  64. drawBox(col, row, boxWidth, boxHeight, colors.lightGray, colors.green)
  65.  
  66. -- Print item name and amount inside the box
  67. term.setBackgroundColor(colors.lightGray)
  68. printInBox(col, row + 2, item.displayName, 1)
  69. printInBox(col, row + 4, "Count: " .. item.amount, 2)
  70. term.setBackgroundColor(colors.black)
  71. end
  72.  
  73. sleep(5) -- Refresh every 5 seconds
  74. end
  75.  
Advertisement
Add Comment
Please, Sign In to add comment