Hi I am new to this mod, I was wondering how would I be able to get a computer to look into a chest and display how much space is left. Just lke the one shown in cc:tweaked main mod page
You can wrap inventories as a peripheral, and then use list() to list the contents of the inventory (https://tweaked.cc/generic_peripheral/inventory.html). For instance, if you just wanted to list the number of slots in use, you could do something like:
local inventory = peripheral.wrap("left") -- Get chest to the left
-- Get the size of the inventory
local total_slots = inventory.size()
-- Count the number of slots in use, and the total number of items
local used_slots, item_count = 0, 0
for slot, item in pairs(inventory.list()) do
used_slots = used_slots + 1
item_count = item.count
end
print("Slots: " used_slots .. " out of " .. total_slots)
print("Have " .. item_count .. " items")
thank you so much, i now have an idea on where to start :)