21 posts
Posted 04 March 2012 - 01:12 PM
Hey everyone,
I apologise in advance if this has already been answered somewhere, but if it has, I can't find it. I'm wondering if turtle.detect("blockname") or turtle.detect("blockid") can work to identify specific blocks? I've tried turtle.detect("Trunk") and turtle.detect("trunk"). I thought they worked at first, but they return true if there is anything in front of the Turtle, not just trunk blocks.
Should I be using blockids? Thanks in advance. :unsure:/>/>
8 posts
Posted 04 March 2012 - 01:17 PM
Yes, Here's an example.
while turtle.detect(log) do
turtle.dig()
print ("Found one log")
end
-- If there is a Log in front of the turtle it will destroy it.
while not turtle.detect(log) do
turtle.forward()
end
-- If there isn't a log in front of the turtle, it will keep going forward.
473 posts
Location
Poland
Posted 04 March 2012 - 01:23 PM
no way, this cannot work. The only way is to mine the thing.
21 posts
Posted 04 March 2012 - 02:00 PM
Unfortunately, it seems that Liraal is right. Thank you for trying to help though, Whoaaaaa.
715 posts
Posted 04 March 2012 - 02:11 PM
@petrus4:
You could fill the inventory slots of the turtle with one sample of each block type that you want to be able to recognize.
Then after every dig operation you check if the number of one of these slots has increased.
If it has, then you know what has been mined.
But since a turtle only has 9 slots this is limited to some degree.
Since it seems that you want to use this for cutting down trees though, this should not be too much of a problem. :unsure:/>/>
473 posts
Location
Poland
Posted 04 March 2012 - 02:24 PM
Well Espen, I already implemented a digSlot function in the API. But that's for diamond mining :unsure:/>/>
21 posts
Posted 04 March 2012 - 03:41 PM
Thanks, Espen. I wonder if dan will implement type detection in future? I can hope so. :unsure:/>/>
715 posts
Posted 04 March 2012 - 04:31 PM
Well Espen, I already implemented a digSlot function in the API. But that's for diamond mining :unsure:/>/>
I hope I'm not derailing this topic too much by asking this, but I took a look at your
digSlot() function and I have to say I'm a bit confused.
If you e.g. use
digSlot(5) but the turtle digs a block that increases
another Slot, e.g. Slot 3, then
digSlot() will drop what's in Slot 3 and return
true.
Whereas if it would've dug a block that actually increased Slot 5, then it would return
false?
So is
digSlot(slotnumber) supposed to return
true if the turtle
didn't mine a block in '
slotnumber', but return
false if it
did? *headscratch*
If that is what's actually happening and if this also is the intended behavior, then could you perhaps explain what exactly the
digSlot() is supposed to do?
I hope you don't mind, it's just that I'm confused and curious at the same time.^^
473 posts
Location
Poland
Posted 04 March 2012 - 04:41 PM
Well, all that except for the true/false, I must've messed them up :unsure:/>/>
The intended behavior is that when mining for diamond, it'll drop everything else (such as cobble). I don't have that perfected yet though, but it works pretty well.
715 posts
Posted 04 March 2012 - 04:45 PM
Ah, ok that explains it then. Thx.
259 posts
Posted 19 March 2013 - 05:37 PM
I know I'm a bit late to the party here, but there is one tedious way, and it only works on things that have a placeable block, like cobble. if you have a piece of cobble in the turtle's currently selected slot, you could do turtle.compare() and as long as there is a cobble block in front of the turtle it will come back true. I really wish there was an easier way, but if there is, I haven't found it.
I did just find a separate mod that works with computercraft, called item analyzer mod (if memory serves) and it can do that, if you want that.
389 posts
Location
Norway
Posted 19 March 2013 - 08:40 PM
Locked to keep the foul magic from spreading D: