cc-tweaked / cc-restitched

Other
80 stars 31 forks source link

getting list() from item vault create does not work #153

Closed Nold0r closed 6 months ago

Nold0r commented 6 months ago

Minecraft Version

1.19.x

Version

1.101.2

Details

hi, I have a problem getting data from the item vault mod create, when I try to get a list of items from the vault, I get nil. I am using CC: Restitched on version 1.19.2 and UnlimitedPeripheralWorks is also installed here is my code :

local groupedItems = {}
for i, itemChest in pairs(chest.list()) do 
    local mod, name = itemChest.name:match("([^:]+):([^:]+)")
    if groupedItems[mod] then
        if (groupedItems[mod])[name]then
            (groupedItems[mod])[name] = (groupedItems[mod])[name] + itemChest.count
        else
            (groupedItems[mod])[name] =  itemChest.count
        end
    else
        groupedItems[mod] = {[name] = itemChest.count}
    end

end
print(textutils.serialise(groupedItems))

the code gets a list of items from the repositories and converts this list into a new sorted one, and then simply outputs a table with the new list to the terminal

Merith-TK commented 6 months ago

Create utilizes a different storage API than the common slot-based one everything else uses

UnlimitedPeripheralWorks implements the ItemStorage API so that it can be used, (I think it works on normal chests as well even)f https://docs.siredvin.site/API/item_storage/

Merith-TK commented 6 months ago

Your code image

Adjusted to use items instead of list image