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

Turtle dropping fuel while slot isn't selected

Started by ammy55, 05 June 2013 - 02:36 PM
ammy55 #1
Posted 05 June 2013 - 04:36 PM
I wrote a mining script that diigs a 3x3 hole to a user specified depth, but it doesn't work. When it goes to drop off it's load it drops its fuel and the chest used to check that it's in the right place. I tried adding print()'s before the slot select, and drop functions and those showed that the slots with its fuel and the chest are only being selected when they should be. Here's the code i'm using, http://pastebin.com/UhLit7EW, I hope someone can tell me why this is messing up.
Lyqyd #2
Posted 05 June 2013 - 04:38 PM
Split into new topic.

There is a bug wherein a turtle instructed to drop items from an empty slot will drop items from the next non-empty slot. Try ensuring that the selected slot contains at least one item before dropping.
ammy55 #3
Posted 05 June 2013 - 04:41 PM
There is a bug wherein a turtle instructed to drop items from an empty slot will drop items from the next non-empty slot. Try ensuring that the selected slot contains at least one item before dropping.
That'd be it then. Glad it wasn't on my end. Do you know if this is fixed in 1.5.2 or if there is a fix in the pipeline?
Also thanks for the instant move and helpful reply.
zazarath #4
Posted 05 June 2013 - 04:45 PM
if you replace your function dropall() with this it should work


function dropall()
for i,1,14,1
  if turtle.getItemCount(i) > 0 then
   turtle.select(i)
   turtle.drop()
  end
end
turtle.select(1)
end
ammy55 #5
Posted 05 June 2013 - 04:56 PM
I had to tweak it a little, but yes that does work! Thank you.
theoriginalbit #6
Posted 05 June 2013 - 10:35 PM
if you replace your function dropall() with this it should work


for i,1,14,1


for i = 1, 14 do
Some notes:
— you must assign i to something, not just comma it.
— @OP there are 16 slots in a turtle, I'm assuming 14 is deliberate?
— if you don't specify an increment of 1 it assumes it
— a for loop must have a `do` after defining the condition or increment.
zazarath #7
Posted 06 June 2013 - 12:47 AM
lol oops i mised do again can you imgine how long it takes me to bug fix =P i still new at this.
also should of realy tested before posting =P