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

[Solved] How to automatically make a turtle switch slots when the current slot is empty?

Started by janiekh, 06 June 2017 - 03:03 PM
janiekh #1
Posted 06 June 2017 - 05:03 PM
I found out how to do it right after I posted this…
I didn't know about while (…) do, which made me figure out how to make it work.


But I do have another problem.
I'm not sure how to make it automatically switch it's selected slot when the current slot is empty.

As I don't know if you can/how you delete posts I'll ask another question here.
If a mod can delete this that would be fine too, I can make another post where the title is actually correct.
Edited on 07 June 2017 - 09:48 AM
Bomb Bloke #2
Posted 07 June 2017 - 12:38 AM
The full-post editor allows you to change thread titles.

To change slot, you'll want to make use of turtle.getItemCount() within another loop. Eg, something along these lines:

local curSlot = 1

while turtle.getItemCount(curSlot) == 0 and curSlot < 16 do
	curSlot = curSlot + 1
end

turtle.select(curSlot)
janiekh #3
Posted 07 June 2017 - 11:48 AM
Thank you and thank you! :)/>