Jump to content




[1.5.1] Auto Farming Bot


3 replies to this topic

#1 Pho3niX90

  • Members
  • 7 posts

Posted 23 September 2012 - 11:22 PM

So tried ComputerCraft for the first time today. And decided to create a Auto Farming BOT, that plows a field, plants a wheat, and then uses bonemeal to instant grow the crop, then takes the wheat..

When the Seeds or bonemeal reaches 1, it will turn to the chests, replenish items, and store wheat.

PLEASE NOTE:
  • The turtle must have a pickaxe, not a hoe.
  • There musn't be a field/crop in-front of the turtle like in the pic, otherwise the turtle will spin in circles looking for a place to plant
Here's the code.

Sourceforge Link: https://sourceforge..../?source=navbar

1.4
term.clear()
term.setCursorPos(1,1)
print("X90 Farming Robot")

while turtle.detect() do
turtle.turnRight()
end

function getSeeds()
turtle.turnLeft()
turtle.select(1)
turtle.drop()
while turtle.getItemCount(1) < 10 do
turtle.suck()
end
turtle.turnRight()
end
function getBone()
turtle.turnRight()
turtle.select(2)
turtle.drop()
while turtle.getItemCount(2) < 10 do
turtle.suck()
end
turtle.turnLeft()
end

function StoreItems()
turtle.turnLeft()
for i=3,16 do
turtle.select(i)
if turtle.compareTo(1) then
turtle.drop()
end
end
turtle.turnRight()
turtle.turnRight()
for i=3,16 do
turtle.select(i)
if turtle.compareTo(2) then
turtle.drop()
end
end
turtle.turnLeft()
turtle.turnRight()
turtle.turnRight()
for i=3,16 do
turtle.select(i)
turtle.drop()
end
turtle.turnLeft()
turtle.turnLeft()
end


Farm = turtle.getItemCount(1)
Bone = turtle.getItemCount(2)
if Farm > Bone then
doTill = Bone
else
doTill = Farm
end
if Farm <= 1 or Bone <= 1 then

StoreItems()
getSeeds()
getBone()

end

i = 1

while i < doTill do
turtle.dig()
turtle.select(1)
turtle.place()
turtle.select(2)
turtle.place()
turtle.dig()
i = i+1
end
os.reboot()

1.5.1
term.clear()
term.setCursorPos(1,1)
print("X90 Farming Robot")
while turtle.detect() do
turtle.turnRight()
end
function getSeeds()
turtle.turnLeft()
turtle.select(1)
if turtle.getItemCount(1) > 0 then
turtle.drop()
end
while turtle.getItemCount(1) < 10 do
turtle.suck()
end
turtle.turnRight()
end
function getBone()
turtle.turnRight()
turtle.select(2)
if turtle.getItemCount(2) > 0 then
turtle.drop()
end
while turtle.getItemCount(2) < 10 do
turtle.suck()
end
turtle.turnLeft()
end
function StoreItems()
turtle.turnLeft()
for i=3,16 do
turtle.select(i)
if turtle.compareTo(1) then
if turtle.getItemCount(i) > 0 then
turtle.drop()
end
end
end
turtle.turnRight()
turtle.turnRight()
for i=3,16 do
turtle.select(i)
if turtle.compareTo(2) then
if turtle.getItemCount(i) > 0 then
turtle.drop()
end
end
end
turtle.turnRight()
for i=3,16 do
turtle.select(i)
if turtle.getItemCount(i) > 0 then
turtle.drop()
end
end
turtle.turnLeft()
turtle.turnLeft()
end

Farm = turtle.getItemCount(1)
Bone = turtle.getItemCount(2)
if Farm > Bone/3 then
doTill = Bone/3
else
doTill = Farm
end
if Farm <= 1 or Bone <= 3 then
StoreItems()
getSeeds()
getBone()
end
i = 1
while i < doTill do
turtle.dig()
turtle.select(1)
turtle.place()
turtle.select(2)
turtle.place()
turtle.place()
turtle.place()
turtle.dig()
i = i+1
end
os.reboot()

Please view attached image to see the setup you must follow to accomplish this.
Attached Image: auto farm bot.png

#2 Bushido

  • New Members
  • 13 posts

Posted 04 October 2012 - 07:20 PM

I have it set up right but it turns to the seed chest and gives the error farm:32: attempt to call nil

If i have the wheat allrdy down it just spins in a circle

#3 Pho3niX90

  • Members
  • 7 posts

Posted 15 October 2012 - 06:45 PM

View PostBushido, on 04 October 2012 - 07:20 PM, said:

I have it set up right but it turns to the seed chest and gives the error farm:32: attempt to call nil

If i have the wheat allrdy down it just spins in a circle

Sorry for only responding now, what turtle are you using? And what version of minecraft and computercraft are you using? Please put a seed in the first slot and let me know what happens.

#4 Pho3niX90

  • Members
  • 7 posts

Posted 08 April 2013 - 08:33 AM

Here is updated code for the new version, this fixes the issue where it drops everything and never farms.

a note to everyone, when first creating your farm, make sure that the pathc where the wheat is in the picture doesn't actually contain a crop, otherwise your turtle will spin in circles looking for a place to start it's own farm.

Also, the code below should be name "startup" program, nothing else.


term.clear()
term.setCursorPos(1,1)
print("X90 Farming Robot")
while turtle.detect() do
turtle.turnRight()
end
function getSeeds()
turtle.turnLeft()
turtle.select(1)
if turtle.getItemCount(1) > 0 then
turtle.drop()
end
while turtle.getItemCount(1) < 10 do
turtle.suck()
end
turtle.turnRight()
end
function getBone()
turtle.turnRight()
turtle.select(2)
if turtle.getItemCount(2) > 0 then
turtle.drop()
end
while turtle.getItemCount(2) < 10 do
turtle.suck()
end
turtle.turnLeft()
end
function StoreItems()
turtle.turnLeft()
for i=3,16 do
turtle.select(i)
if turtle.compareTo(1) then
if turtle.getItemCount(i) > 0 then
turtle.drop()
end
end
end
turtle.turnRight()
turtle.turnRight()
for i=3,16 do
turtle.select(i)
if turtle.compareTo(2) then
if turtle.getItemCount(i) > 0 then
turtle.drop()
end
end
end
turtle.turnRight()
for i=3,16 do
turtle.select(i)
if turtle.getItemCount(i) > 0 then
turtle.drop()
end
end
turtle.turnLeft()
turtle.turnLeft()
end

Farm = turtle.getItemCount(1)
Bone = turtle.getItemCount(2)
if Farm > Bone/3 then
doTill = Bone/3
else
doTill = Farm
end
if Farm <= 1 or Bone <= 3 then
StoreItems()
getSeeds()
getBone()
end
i = 1
while i < doTill do
turtle.dig()
turtle.select(1)
turtle.place()
turtle.select(2)
turtle.place()
turtle.place()
turtle.place()
turtle.dig()
i = i+1
end
os.reboot()






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users