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

Using a turtle to milk a cow

Started by ASPEEDYNINJA, 26 October 2013 - 04:36 PM
ASPEEDYNINJA #1
Posted 26 October 2013 - 06:36 PM
Title:Using a turtle to milk a cow

I am trying to use a turtle to milk a cow so that i can automate the collection of milk. So far i have been able to get most of it working the only think i cant get to work is the filling of the filling of the buckets.
The problem is when it sucks buckets because they now stack it can pick up more then one, i dont know how to make it only suck one or the way i was trying to get it to work was to count how many buckets it has then milk the cow the right amount of times depending on the amount of buckets.

here is my code please don't judge me i'm new to this so it might be a bit messy :P/>

function suck()
while not turtle.suck() do
sleep(1)
end
end

function getBucket()
turtle.turnLeft()
suck()
turtle.turnRight()
end

function dropMilk()
turtle.turnRight()
turtle.turnRight()
for vSlot = 1, 16, 1 do
turtle.select(vSlot)
turtle.drop()
end
turtle.turnLeft()
turtle.turnLeft()
end

function milk()
turtle.select(1)
turtle.getItemCount(1) = i
for i do
turtle.place()
end

while true do
getBucket()
milk()
dropMilk()
sleep(1)
end
Lyqyd #2
Posted 26 October 2013 - 07:21 PM
Split into new topic.

You'd need to use i = turtle.getItemCount(1), not the other way around. You can call turtle.drop with a number argument to tell it how many items to drop:


turtle.suck()
turtle.drop(turtle.getItemCount(1) - 1)
awsmazinggenius #3
Posted 28 October 2013 - 07:01 PM
Just curious. Can you actually farm milk with a Turtle? I didn't know it was possible.