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

Turtle won't drop items.

Started by Robyn Banks, 12 January 2016 - 01:30 AM
Robyn Banks #1
Posted 12 January 2016 - 02:30 AM
I'm new to computercraft, this should be an easy fix but I don't know what's wrong.
The program is supposed to kill mobs(which works fine) and when it checks slot 16, if it has an item in that slot, it throws them in front of it. I can't get the turtle to drop the items from its inventory.

while true do
  turtle.attack()
  sleep(1)
  end 
if  turtle.getItemCount(16) <1 then
for i = 1, 16 do
turtle.select(i)
turtle.drop()
end
end
Bomb Bloke #2
Posted 12 January 2016 - 07:20 AM
That code never checks line 16, because you've built a loop above your check which never ends.

Your check is also not looking to see if something is in the slot, but rather it's checking to see if it's empty. Less than one == zero, in this instance.
Edited on 12 January 2016 - 06:21 AM