Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rs = peripheral.find("rsBridge")
- monitor = peripheral.find('monitor')
- -- Redirects writes to monitor (if any)
- term.redirect(monitor)
- w, h = monitor.getSize() -- Get monitor width and height
- boxWidth = 15 -- Width of each box
- boxHeight = 8 -- Height of each box (including border)
- boxesPerRow = math.floor(w / boxWidth)
- rows = math.floor(h / boxHeight)
- -- Draws a box with a green outer edge
- function drawBox(x, y, width, height, innerColor, borderColor)
- -- Outer green border (1 pixel larger)
- paintutils.drawFilledBox(x, y, x + width, y + height, borderColor)
- -- Inner light grey box (slightly smaller for border effect)
- paintutils.drawFilledBox(x + 1, y + 1, x + width - 1, y + height - 1, innerColor)
- -- Optional black outline for sharpness
- paintutils.drawBox(x, y, x + width, y + height, colors.black)
- end
- -- Prints text inside the box
- function printInBox(x, y, text, lineOffset)
- term.setCursorPos(x + 1, y + lineOffset)
- displayText = text
- if #displayText > boxWidth - 2 then
- displayText = string.sub(displayText, 1, boxWidth - 3) .. "..."
- end
- term.write(displayText)
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- rsitems = rs.listItems()
- -- Filter items with 1000+ count
- filteredItems = {}
- for _, item in pairs(rsitems) do
- if item.amount >= 1000 then
- table.insert(filteredItems, item)
- end
- end
- -- Sort filtered items from largest to smallest
- table.sort(filteredItems, function(a, b)
- return a.amount > b.amount
- end)
- -- Render items inside boxes
- for i, item in ipairs(filteredItems) do
- col = ((i - 1) % boxesPerRow) * boxWidth + 1
- row = math.floor((i - 1) / boxesPerRow) * boxHeight + 1
- -- Break if exceeding screen space
- if row + boxHeight > h then
- break
- end
- -- Draw box with outer green edge and light grey inner fill
- drawBox(col, row, boxWidth, boxHeight, colors.lightGray, colors.green)
- -- Print item name and amount inside the box
- term.setBackgroundColor(colors.lightGray)
- printInBox(col, row + 2, item.displayName, 1)
- printInBox(col, row + 4, "Count: " .. item.amount, 2)
- term.setBackgroundColor(colors.black)
- end
- sleep(5) -- Refresh every 5 seconds
- end
Advertisement
Add Comment
Please, Sign In to add comment