-- peripheral setup local import = peripheral.wrap("right") local export = peripheral.wrap("left") peripheral.find("modem", rednet.open) -- variables setup local items = {} function stripModName(itemname) local parts= {} for part in itemname:gmatch("[^:]+") do parts[ #parts + 1 ] = part end return parts[2] end function stripEssence(itemname) return itemname:gsub("_essence", "") end function addItem(item) local name = stripModName(item.name) name = stripEssence(name) if items[name] then items[name] = items[name] + item.count else items[name] = item.count end end function waitForRequest() parallel.waitForAny(wait,getRequest) end function wait() sleep(0.5) end function getRequest() local sender, message, protocol = rednet.receive() if message == "provideEssenceCount" then rednet.send(sender, items, protocol) end end while true do for i=1,27 do local item = import.getItemDetail(i) if item then addItem(item) import.pushItems(peripheral.getName(export), i, item.count) end end waitForRequest() end