Skip to content

Instantly share code, notes, and snippets.

@TomyLobo
Last active October 4, 2015 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomyLobo/8a38d331436b4173db58 to your computer and use it in GitHub Desktop.
Save TomyLobo/8a38d331436b4173db58 to your computer and use it in GitHub Desktop.
ComputerCraft turtle to patrol a rectangular area delimited by obsidian blocks
shell.run('clear')
print("Please put obsidian in Slot 1 and mark the corners with obsidian.")
print("Go clockwise? (y/N)")
local clockwise = io.read():upper() == "Y"
local obsidian = 1
print("Going "..(clockwise and "clockwise" or "counter-clockwise")..".")
while true do
turtle.select(obsidian)
repeat
for i = 1, 3 do
turtle.attack()
turtle.attackUp()
end
turtle.forward()
until turtle.compareDown()
if clockwise then
turtle.turnRight()
else
turtle.turnLeft()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment