This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
legendA's profile picture

turtle drop item code

Started by legendA, 04 September 2012 - 03:47 PM
legendA #1
Posted 04 September 2012 - 05:47 PM
i was wondering if the was a code that would drop items like cobblestone when its mined but still leave the good things like diamonds.
OmegaVest #2
Posted 04 September 2012 - 07:40 PM
Not like you are thinking. Although, if you had a piece of cobblestone in slot 1 at all times and then did something like this, it would drop all cobble, but anything else it would keep.



function dropCobble(slot)
   turtle.select(slot)
   turtle.drop(turtle.getItemCount() - 1)
end

And then just call that function whenever you dig. Or after a certain amount of digs.

And, just so you know, the call should look like this is cobble is in slot 1.


dropCobble(1)
legendA #3
Posted 05 September 2012 - 07:14 PM
thants not what i wanted because then it would drop anything in that slot so even if i put a cobble in that slot if it mined dirt it would drop the last piece of cobble. now i could get that to work if i threw in a detect with that code but i want it to drop it when its mined and not go to the inventory.
OmegaVest #4
Posted 05 September 2012 - 10:53 PM
Well, obviously it would also work for multiple slots. But it will never work without something to compare it to. And it will always drag it into the inventory first, but using my code that is little worry, really.

What you are looking for is a smart turtle. What is included really isn't. There is a peripheral that might work, but I don't know how well, and I can't remember its name.
Pharap #5
Posted 06 September 2012 - 03:56 AM
This is one of my main arguments for turtles being able to identify items.
There are several APIs and peripherals that may help, but none come to mind other than MagicTurtle.
legendA #6
Posted 06 September 2012 - 02:36 PM
alright i guess this is hopeless then. on to plan 2 does anyone know a code that when the bot is full it goes to a certian spot to drop its invantory and when its empty go back to where it came stopped and start where it left off.
sjele #7
Posted 06 September 2012 - 02:54 PM
Try this: (This will get messed up if it hit's sand) (It is only the going forward/back part)


repeat
a = turtle.getItemCount(1)
b = turtle.getItemCount(2)
c = turtle.getItemCount(3)
d = turtle.getItemCount(4)
e = turtle.getItemCount(5)
f = turtle.getItemCount(6)
g = turtle.getItemCount(7)
h = turtle.getItemCount(8)
i = turtle.getItemCount(9)
turtle.forward()
dist = dist + 1
until a ==64 or b == 64 or c == 64 or d == 64 or e == 64 or f == 64 or g == 64 or h == 64 or i == 64
repeat
turtle.back()
dist = dist - 1
until dist == 0

legendA #8
Posted 06 September 2012 - 06:24 PM
no that wouldnt work with my code. i would need to have xyz coridnates.