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

Turtle.(un)lock()

Started by Cruor, 01 September 2012 - 07:39 PM
Cruor #1
Posted 01 September 2012 - 09:39 PM
This is majorly a suggestion to get turtles to work better with turtle.suck() and blocks that pulls items out of inventories(RP filter, BC woodenpipe etc).

turtle.lock() will "lock" the turtle inventory to the current slot, not locking as in "you cannot change away from this slot" but in a way that this selected slot is the only slot avaible for inventory manipulations. Why? Currently when getting items pulled out of its inventory it will take it from slot 1 in the turtle, even if slot 10 is selected. This makes "programmable intersections" quite hard as you would want it to pull out of slot 10 and not slot 1.

TL;DR version: turtle.lock() uses only the selected slot for all inventory manipulation, turtle.unlock() reverts back to normal.
Jan #2
Posted 01 September 2012 - 11:08 PM
This is majorly a suggestion to get turtles to work better with turtle.suck() and blocks that pulls items out of inventories(RP filter, BC woodenpipe etc).

turtle.lock() will "lock" the turtle inventory to the current slot, not locking as in "you cannot change away from this slot" but in a way that this selected slot is the only slot avaible for inventory manipulations. Why? Currently when getting items pulled out of its inventory it will take it from slot 1 in the turtle, even if slot 10 is selected. This makes "programmable intersections" quite hard as you would want it to pull out of slot 10 and not slot 1.

TL;DR version: turtle.lock() uses only the selected slot for all inventory manipulation, turtle.unlock() reverts back to normal.

You can easily work around this (I think )

Instead of pulling items out of a turtle, let the turtle drop the items! Dropping is very precise, you can turtle.select() the slot and choose how many to drop.
Let the turtle listen to rednet, and send a message to it when it should drop.
Cruor #3
Posted 02 September 2012 - 09:27 AM
This is majorly a suggestion to get turtles to work better with turtle.suck() and blocks that pulls items out of inventories(RP filter, BC woodenpipe etc).

turtle.lock() will "lock" the turtle inventory to the current slot, not locking as in "you cannot change away from this slot" but in a way that this selected slot is the only slot avaible for inventory manipulations. Why? Currently when getting items pulled out of its inventory it will take it from slot 1 in the turtle, even if slot 10 is selected. This makes "programmable intersections" quite hard as you would want it to pull out of slot 10 and not slot 1.

TL;DR version: turtle.lock() uses only the selected slot for all inventory manipulation, turtle.unlock() reverts back to normal.

You can easily work around this (I think )

Instead of pulling items out of a turtle, let the turtle drop the items! Dropping is very precise, you can turtle.select() the slot and choose how many to drop.
Let the turtle listen to rednet, and send a message to it when it should drop.

While this is true, it still dosnt allow for turtle to suck up items to the only selected slot. Else than that it is a valid workaround.
Jan #4
Posted 02 September 2012 - 10:12 AM
Maybe this script solves the problem?

slot=1
turtle.select(slot)
while turtle.getItemCount(slot)<1 do
turtle.suck()
end

I don't like solving problems the easiest way :)/>/>
matejdro #5
Posted 02 September 2012 - 09:10 PM
We solve this by simply having a chest next to a turtle. Turtle drops everything that it wants into a chest and then engine will just pull out of a chest instead of a turtle.

As for sucking, you can do some checks. If selected slot is full, there is a chance that items might land in another slot, so switch to a first empty slot to have save "sucking".