Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("back")
- modem.open(57)
- local chests = {
- "InventoryInterface_17","InventoryInterface_18","InventoryInterface_19",
- "InventoryInterface_20","InventoryInterface_21","InventoryInterface_22",
- "InventoryInterface_24","InventoryInterface_25","InventoryInterface_26",
- "InventoryInterface_27","InventoryInterface_28"
- }
- Storage = peripheral.wrap("InventoryInterface_34")
- local data = {}
- local s = false
- for i = 1,#chests do
- data[i] = peripheral.wrap(chests[i])
- end
- --WOW
- function getStorage()
- local tab = {}
- for m = 1,#data do
- for i=1, data[m].getInventorySize() do
- slot = data[m].getItemInSlot(i)
- if slot["name"] then
- tab[slot.name:gsub("minecraft:","")..":"..slot.metadata] = (tab[slot.name:gsub("minecraft:","")..":"..slot.metadata] or 0) + slot.stackSize
- end
- end
- end
- return(tab)
- end
- while true do
- event,_,_,_,msg = os.pullEvent("modem_message")
- if msg == "Request" then
- modem.transmit(57,1,textutils.serialize(getStorage()))
- else
- u = 1
- t = textutils.unserialize(msg)
- count = t[2]
- for m = 1,#data do
- for i=1, data[m].getInventorySize() do
- slot = data[m].getItemInSlot(i)
- if slot["name"] then
- if (slot["name"]:gsub("minecraft:","")..":"..slot.metadata) == t[1] then
- count = count - slot.stackSize
- print(count)
- if count >= 0 then
- data[m].transferToII(Storage.uuid(),i,u,(slot.stackSize))
- u = u+1
- else
- data[m].transferToII(Storage.uuid(),i,u,(count +slot.stackSize))
- break
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment