Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getItemsOfType(itemType)
- local toReturn = 0
- local i = 1
- while i<=16 do
- local itemCount = turtle.getItemCount(i)
- if (itemCount > 0) then
- if (turtle.getItemDetail(i).name == itemType) then
- toReturn = toReturn+itemCount
- end
- end
- i = i + 1
- end
- return toReturn
- end
- function dropSpecificItemsOfType(itemType,n)
- local returned = 0
- local i = 1
- while i<=16 do
- if n~=returned then
- local itemCount = turtle.getItemCount(i)
- if (itemCount > 0) then
- if (turtle.getItemDetail(i).name == itemType) then
- turtle.select(i)
- if (n-returned > 64) then --Daca tre mai mult de un stack, drop la tot
- turtle.drop();
- returned = returned + 64
- else
- turtle.drop(n-returned)
- returned = n
- end
- end
- end
- i = i + 1
- else
- break
- end
- end
- end
- cobbleID = "minecraft:cobblestone"
- resinID = "ic2:itemharz"
- --ic2:itemharz
- totalCobblestone = 0
- totalResin = 0
- while true do
- local event, p1 = os.pullEvent("turtle_inventory")
- local currentCobblestone = getItemsOfType(cobbleID)
- local currentResin = getItemsOfType(resinID)
- print("Current cobble,resin in inv:"..currentCobblestone.." "..currentResin)
- totalCobblestone = totalCobblestone + currentCobblestone
- totalResin = totalResin + currentResin
- print("Total cobblestone, resin: "..totalCobblestone.." "..totalResin)
- dropSpecificItemsOfType(cobbleID,currentCobblestone)
- dropSpecificItemsOfType(resinID,currentResin)
- if totalResin < totalCobblestone then
- redstone.setOutput("right",true)
- else
- redstone.setOutput("right",false)
- totalCobblestone = 0
- totalResin = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement