games:minecraft:public:computer_craft:notable_turtle_programs

This is an old revision of the document!


Notable Turtle Programs

From ChatGPT

-- This turtle will plant and harvest a 20 by 20 area

-- First, define the size of the area
local area_width = 20
local area_length = 20

-- Next, move the turtle to the starting position
-- (assume that the turtle is facing the correct direction)
turtle.forward()

-- Now, loop through the rows
for i=1,area_length do
  -- Plant seeds on this row
  for j=1,area_width do
    turtle.placeDown()
    turtle.forward()
  end

  -- Move the turtle back to the beginning of the row
  for j=1,area_width do
    turtle.back()
  end

  -- Move the turtle to the next row
  turtle.turnRight()
  turtle.forward()
  turtle.turnRight()
end

-- Now, the turtle is at the end of the last row
-- Move it back to the starting position
for i=1,area_length do
  turtle.back()
end
turtle.turnLeft()
for i=1,area_width do
  turtle.back()
end
turtle.turnLeft()

-- The turtle is now back at the starting position
-- Loop through the rows again to harvest the crops
for i=1,area_length do
  -- Harvest the crops on this row
  for j=1,area_width do
    turtle.digDown()
    turtle.forward()
  end

  -- Move the turtle back to the beginning of the row
  for j=1,area_width do
    turtle.back()
  end

  -- Move the turtle to the next row
  turtle.turnRight()
  turtle.forward()
  turtle.turnRight()
end

-- Now, the turtle is at the end of the last row
-- Move it back to the starting position
for i=1,area_length do
  turtle.back()
end
turtle.turnLeft()
for i=1,area_width do
  turtle.back()
end
turtle.turnLeft()

-- Done!

This script will plant seeds in a 20 by 20 area and then return to the starting position to harvest the crops. Note that this script assumes that the turtle has enough seeds and fuel to complete the task, and that it is facing the correct direction when it starts.

  • games/minecraft/public/computer_craft/notable_turtle_programs.1670734921.txt.gz
  • Last modified: 2022/12/11 05:02
  • by clay