Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load necessary APIs and peripherals
- local me = peripheral.wrap("meBridge_3")
- -- Set up the monitor(s)
- local monitor_side = "left" -- Change this to match the side where your monitor is located
- local monitor = peripheral.wrap(monitor_side)
- monitor.setTextScale(0.5) -- Adjust the text scale as needed for your monitor size
- -- Set up the display parameters
- local item_column_width = 25
- local count_column_width = 10
- local num_columns = math.floor(monitor.getSize() / (item_column_width + count_column_width))
- -- Set up the refresh interval (in seconds)
- local refresh_interval = 5
- function display_items()
- -- Get the list of items from the ME storage system
- local items = me.listItems()
- -- Clear the monitor
- monitor.clear()
- -- Display the header row
- monitor.setCursorPos(1,1)
- monitor.write("Item" .. string.rep(" ", item_column_width - 4) .. "Count")
- -- Display each item and its count in a row
- local row = 2
- for i, item in ipairs(items) do
- local col = (i-1) % num_columns + 1
- local _, item_start = string.find(item.name, ":")
- local item_name = item.name:gsub("_", " "):sub(item_start + 1, item_start + item_column_width)
- monitor.setCursorPos((col-1) * (item_column_width + count_column_width) + 1, row)
- monitor.write(item_name)
- monitor.setCursorPos(col * (item_column_width + count_column_width) - count_column_width + 1, row)
- monitor.write(tostring(item.amount):sub(1, count_column_width))
- if col == num_columns then
- row = row + 1
- end
- end
- end
- -- Loop to update the display at regular intervals
- while true do
- display_items()
- sleep(refresh_interval)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement