This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Mining Turtle to dump cobble, dirt?
Started by allbad, 04 May 2012 - 01:29 AMPosted 04 May 2012 - 03:29 AM
How do I get the mining turtle to dump the junk I don't want like cobblestone and dirt? I know to fill the 9 slots with a single of what I want, but I'd rather do some kind of turtle.detectItemInSlot(<num>) and if it's on a dump list it drops it.
Posted 04 May 2012 - 04:32 AM
Unfortunately, it's not possible… and not going to be possible. Turtles are supposed to be blind, hand-less golems that can only move around and bash things mindlessly.
Posted 04 May 2012 - 05:30 AM
You could do this, just would need to setup a couple of blocks to run turtle.compare() against then turtle.drop() if its true.
Posted 04 May 2012 - 06:09 AM
The best way to do this I think is to have a slot thats purely for cobble etc.
Slot in this case is 1.
This will drop the blocks there if its full and mine the new block.
Meaning this should work just fine for making sure cobble will never take over one slot.
You could also just have some code to dump the "trash" if your inv is full.
Slot in this case is 1.
turtle.select(1)
if turtle.compare(1) and turtle.getItemCount(1) > 63 then
turtle.drop()
end
turtle.dig()
This will drop the blocks there if its full and mine the new block.
Meaning this should work just fine for making sure cobble will never take over one slot.
You could also just have some code to dump the "trash" if your inv is full.
Posted 04 May 2012 - 02:36 PM
libraryaddict, that's it! When I go mining, a good 80% of what's collected is cobble. Just by taking up 1 slot in the turtle I'm probably freeing up 5 others that'll be taken over. You are a genius.
Posted 04 May 2012 - 02:48 PM
oh wait… I'm comparing a stone block in front of me to a cobble block in slot 1. That's not gonna work.
Posted 04 May 2012 - 03:03 PM
Good point.
Hmm.
Maybe just have 2 slots for stone/cobble?
if turtle slot 2 is full. drop it.
If turtle slot 2 is full but not cobble.
then drop slot one.
With it remembering if its cobble or not in there.
Hmm.
Maybe just have 2 slots for stone/cobble?
if turtle slot 2 is full. drop it.
If turtle slot 2 is full but not cobble.
then drop slot one.
With it remembering if its cobble or not in there.
Posted 05 May 2012 - 12:54 AM
well, poo… my server (bukkit) is sufferring from this bug:
turtle.compare() always returns true
http://www.computercraft.info/forums2/index.php?/topic/842-131-for-mc11smp-turtlecompare-allways-returns-true/
Guess I'll have to put this one on the backburner.
Thanks for the ideas libraryaddict, it works in vanilla.
turtle.compare() always returns true
http://www.computercraft.info/forums2/index.php?/topic/842-131-for-mc11smp-turtlecompare-allways-returns-true/
Guess I'll have to put this one on the backburner.
Thanks for the ideas libraryaddict, it works in vanilla.
Posted 02 September 2013 - 07:18 PM
Read my post below.
Posted 02 September 2013 - 07:33 PM
Hey guys try this: (Set slot 1 to stone, slot 2 to cobblestone, and slot 3 to dirt)
turtle.select(1)
if turtle.compare(1) and turtle.getItemCount(2) > 63 then
turtle.select(2)
turtle.drop()
end
turtle.select(3)
if turtle.compare(3) and turtle.getItemCount(3) > 63 then
turtle.drop()
end
Hopefully that works!
Actually, you might want to make dirt slot 1, stone slot 2, and cobble slot 3 like this: (because then dirt becomes the placedown block for when it comes back up)
turtle.select(2)
if turtle.compare(2) and turtle.getItemCount(3) > 63 then
turtle.select(3)
turtle.drop()
end
turtle.select(1)
if turtle.compare(1) and turtle.getItemCount(1) > 63 then
turtle.drop()
end
Posted 03 September 2013 - 03:22 AM
Read my post below.
The mad necros :)/>
Posted 03 September 2013 - 10:34 AM
oh wait… I'm comparing a stone block in front of me to a cobble block in slot 1. That's not gonna work.
You can cook cobble in a basic furnace to get your stone block that you can use for comparison.
Posted 03 September 2013 - 03:20 PM
You actually don't need to compare anything. If you select slot 1, the items will always be put into the first slot that they can go into, just like shift-clicking the item in the turtle's inventory. Before or after digging, you just check if the junk-slots are close to full and drop all the items but one per junk-slot:
turtle.select(1)
turtle.dig()
for slot = 1, 4 do -- junk-slots are slots 1 through 4
if turtle.getItemSpace(slot) < 5 then
turtle.select(slot)
turtle.drop(turtle.getItemCount(slot) - 1)
end
end
I hope this helps.