31 posts
Posted 15 May 2012 - 10:24 PM
Have any way to only catch a defined item?
1604 posts
Posted 15 May 2012 - 11:01 PM
You can give the turtle (put in some slot of the turtle) the block you want it to dig, then use the compare function to know if it's the block you want and if it is then dig it, otherwise it keeps looking, maybe droping any unwanted blocks.
Example:
local slot = 1 -- slot of the block to dig
local function isBlock()
turtle.select(slot)
return turtle.compare()
end
while true do
if isBlock() then
turtle.dig()
turtle.forward()
else
turtle.turnRight()
end
end
Of course, this has to be changed a lot to do something usefull, but I hope you get the idea of it.
31 posts
Posted 15 May 2012 - 11:06 PM
Hmm, i can do to dig, and if not is the item that i wanted, drop and keep digging until i find my item?
1604 posts
Posted 15 May 2012 - 11:39 PM
Yes, you compare to see if it's the block, dig it, and if was not the correct one drop it. The compare function compares the item in the selected slot with the block in front of the turtle, that's why you have to compare and then dig.
31 posts
Posted 16 May 2012 - 01:10 AM
Okay, Thnks :P/>/>
59 posts
Location
Washington, United States
Posted 18 May 2012 - 01:50 AM
heh, I use turtle.compare() myself. I'm thinking of using the comparison function for a path follower. eg. block 1 would be path block, and block 2 would be turn block, etc.