I'm not usually in this section, so you'll have to pardon me for only knowing English. I was just burning time at the lab I work in, and I made a small script for the turtle robot in feed the beast. Before I post the code, be aware that there are betters ways to do this. If I redo the project, I would change the shape of the field into something more efficient, same with the starting position of the turtle. Anyways, here's the field:
Behind the scenes, you can see that coal is pumped into a chest on the top of the turtle. The turtle should have seeds in the first slot of the turtle. Coal can be anywhere in the turtle for fuel. If there is no fuel to continue, the turtle will stop and wait for fuel.
Here's the script:

Also, below:
Code:
-- Configuration:
seedsSlot = 1
-- Checks if the fuel level is low and refuels. Finds fuel
-- in the turtle's inventory.
checkFuel = function()
while turtle.getFuelLevel() < 1 do
for s = 2, 16 do
if turtle.select(s) then
if turtle.getFuelLevel() < 1 then
turtle.refuel(s)
else break
end
end
end
-- Alert the user if the turtle is out of fuel.
if turtle.getFuelLevel() < 1 then
print("Warning - out of fuel.")
sleep(5)
end
end
end
-- Prepares the seeds slot to plant crop.
prepareSeeds = function()
turtle.select(seedsSlot)
if turtle.getItemCount(seedsSlot) == 1 then
for index = 2, 16 do
if turtle.compareTo(index) then
turtle.select(index)
turtle.transferTo(seedsSlot, turtle.getItemCount(index))
turtle.select(seedsSlot)
end
end
end
end
-- Takes a step forward. Checks fuel for each step.
forward = function(n)
for index = 1, n do
checkFuel()
turtle.forward()
end
end
-- Harvests the crop below the turtle, then replants the
-- crop using seeds from the configured seeds slot. Moves
-- forward to the next space if not the last space.
harvest = function(n)
for index = 1, n do
turtle.digDown()
turtle.suckDown()
prepareSeeds()
turtle.placeDown()
if index ~= n then
forward(1)
end
end
end
-- Turns the turtle to the right.
right = function()
turtle.turnRight()
end
-- Turns the turtle to the left.
left = function()
turtle.turnLeft()
end
-- Makes the turtle turn around.
uturn = function()
turtle.turnLeft()
turtle.turnLeft()
end
-- Dumps the inventory into the chest below it.
dump = function()
for s = 2, 16 do
if turtle.select(s) then
turtle.dropDown(turtle.getItemCount(s))
end
end
end
-- Gets fuel from the chest above it.
getFuel = function()
for s = 2, 16 do
if turtle.select(s) and turtle.getItemCount(s) == 0 then
turtle.suckUp()
break
end
end
end
-- Output the header for the program
print("Farming Turtle Program")
print("Developed by Spirited Fang")
print(" ")
print("Obtaining Fuel...")
getFuel()
print("Now farming left side...")
forward(1)
left()
forward(3)
harvest(5)
right()
forward(1)
right()
harvest(7)
left()
forward(1)
left()
harvest(7)
right()
forward(1)
right()
harvest(5)
left()
forward(1)
left()
forward(1)
harvest(4)
right()
forward(1)
right()
harvest(3)
left()
forward(1)
left()
harvest(3)
right()
forward(1)
right()
harvest(3)
left()
forward(1)
left()
harvest(3)
right()
forward(1)
right()
harvest(3)
forward(1)
left()
forward(1)
left()
harvest(4)
right()
forward(1)
right()
harvest(5)
forward(2)
left()
forward(1)
left()
harvest(7)
right()
forward(1)
right()
harvest(7)
left()
forward(1)
left()
harvest(7)
uturn()
forward(8)
print("Now farming right side...")
harvest(7)
right()
forward(1)
right()
harvest(7)
left()
forward(1)
left()
harvest(7)
right()
forward(1)
right()
harvest(5)
left()
forward(1)
left()
forward(1)
harvest(4)
right()
forward(1)
right()
harvest(3)
left()
forward(1)
left()
harvest(3)
right()
forward(1)
right()
harvest(3)
left()
forward(1)
left()
harvest(3)
right()
forward(1)
right()
harvest(3)
forward(1)
left()
forward(1)
left()
harvest(4)
right()
forward(1)
right()
harvest(5)
forward(2)
left()
forward(1)
left()
harvest(7)
right()
forward(1)
right()
harvest(7)
left()
forward(1)
left()
forward(2)
harvest(5)
print("Going Home...")
uturn()
forward(7)
left()
forward(2)
print("Dumping crops...")
dump()
uturn()
forward(1)
print("Task Completed.")
Kind Regards,
Fang






