Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rIronName = "IC2:item.itemIngotAdvIron"
- cCableName = "IC2:item.ic2cable"
- glassName = "minecraft:glass"
- coalDustName = "IC2:item.itemDustCoal"
- redstoneName = "minecraft:redstone"
- tinName = "IC2:item.itemIngotTin"
- cobbleName = "minecraft:cobblestone"
- circuitName = "IC2:item.itemPartCircuit"
- generatorName = "IC2:blockGenerator"
- furnaceName = "minecraft:furnace"
- casingName = "IC2:blockMachine"
- batteryName = "IC2:item.itemBatRE"
- items = {}
- function findNextEmptySlot()
- for x=1,16 do
- if turtle.getItemCount(x) == 0 then
- return x
- end
- end
- end
- function listenForRequest()
- print("Waiting on item to be requested from my buddy...")
- sID, msg, prot = rednet.receive("solar")
- print("My buddy requested: " .. msg[2] .. " " .. msg[1])
- return msg
- end
- function findItem(itemName)
- for k,v in ipairs(items) do
- if v.name == itemName then
- return k
- end
- end
- return 0
- end
- function giveItems(slotNum, count)
- turtle.select(slotNum)
- turtle.dropDown(count)
- print("Gave my buddy " .. count .. " " .. items[slotNum].name)
- rednet.send(11,"Sent",solar")
- items[slotNum].count = items[slotNum].count - count
- if items[slotNum].count == 0 then
- items[slotNum] = nil
- end
- end
- function rescanInv()
- for x=1,16 do
- tmp = turtle.getItemDetail(x)
- if tmp ~= nil then
- items[x] = tmp
- end
- end
- end
- function getAll()
- rescanInv()
- for x=1,16 do
- slot = findNextEmptySlot()
- if slot == 0 then
- return
- end
- turtle.select(slot)
- turtle.suck()
- items[slot] = turtle.getItemDetail(x)
- end
- end
- rednet.open("right")
- running = true
- while running do
- getAll()
- item = listenForRequest()
- i = findItem(item[1])
- if i ~= 0 and turtle.getItemDetail(i).count >= item[2] then
- giveItems(i, item[2])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement