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

Turtle will not take or deposit items?

Started by aperson321, 17 March 2013 - 02:00 PM
aperson321 #1
Posted 17 March 2013 - 03:00 PM
I found this code on the FTB forums nut it does not seem to take the items from the chest or deposit them into a chest and I was wondering if anyone had any ideas.


while true do
	if turtle.getItemCount(1) == 1 and turtle.getItemCount(2) == 1 then-- if the turtle has an item in slot 1 and 2
		turtle.select(1)-- select first slot
		if not turtle.craft() then-- try to craft the two swords together, if it doesn't work, one was already fully repaired
			for i = 1,2 do-- try to put both swords down into the barrel (only the fully repaired will go in)
				turtle.select(i)
				turtle.dropDown()
			end
		end
	else-- if the turtle does not have an item in slot 1 and 2
		turtle.suck()-- get another item from the input chest
	end
end
Edited by
Lyqyd #2
Posted 17 March 2013 - 03:40 PM
Split into new topic.
KaoS #3
Posted 17 March 2013 - 05:46 PM

while true do
    for i=3,16 do --drop all items in the other slots in case they are getting in the way of the craft, this will not slow down your script because it only selects the slot when it has items
        if turtle.getItemCount(i)>0 then
            turtle.select(i)
            turtle.dropUp()
        end
    end
    if turtle.getItemCount(1) == 1 and turtle.getItemCount(2) == 1 then
        if not turtle.craft() then
            for i = 1,2 do
                turtle.select(i)
                turtle.dropDown()
            end
        else --you gotta drop the repaired sword if repair is successfull as well
            turtle.select(1)
            turtle.dropDown()
        end
    else
        for i=1,2 do --you need to suck into the right slots
            turtle.select(i)
            while turtle.getItemCount(i)<1 do turtle.suck() end--keep trying until you get a sword
        end
    end
end