<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.computercraft.info/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Requios</id>
		<title>ComputerCraft Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://www.computercraft.info/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Requios"/>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/Special:Contributions/Requios"/>
		<updated>2026-07-11T08:45:05Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=7440</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=7440"/>
				<updated>2016-06-13T18:15:12Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It also strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling, for example, it will not get stopped by mobs, players, sand, or any other block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Find minecraft/mods/computercraft.jar and change its extension to .zip (make sure the file browser doesn't hide extensions).&lt;br /&gt;
* Inside the zip, navigate to assets/computercraft/lua/rom/apis/turtle (if you are running on a server, only the server needs the file).&lt;br /&gt;
* Save the code beneath as 't' (without '.txt'), so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
* Change the extension back to .jar (optional, mods tend to work as .zip too).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks. There are also some functions that combine default functions for ease of use. E.g. turnAround() turns right twice.&lt;br /&gt;
&amp;lt;br/&amp;gt;Most of the function names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand falls down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. It combines selecting and placing. &lt;br /&gt;
&amp;lt;br/&amp;gt;I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;If there is another block in the way, it will break it, unless it is the same type of block.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;The following function places a row of blocks: &lt;br /&gt;
* t.placeRow(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. The possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeRow(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. &lt;br /&gt;
&amp;lt;br/&amp;gt;This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can change it to turn left twice ;).&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn back again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Download: [http://pastebin.com/0TnEBf2P Robust Turtle API]&lt;br /&gt;
&amp;lt;br/&amp;gt;Save it as 't', without &amp;quot;.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Robust Turtle API by SpeedR&lt;br /&gt;
&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug up for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug down for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place row     e.g. placeRow(up, marble, forward, 15)&lt;br /&gt;
function placeRow(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=7439</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=7439"/>
				<updated>2016-06-13T15:05:49Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: Updated installation instructions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It also strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling, for example, it will not get stopped by mobs, players, sand, or any other block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Find minecraft/mods/computercraft.jar and change its extension to .zip (make sure the file browser doesn't hide extensions).&lt;br /&gt;
* Inside the zip, navigate to assets/computercraft/lua/rom/apis/turtle (if you are running on a server, only the server needs the file).&lt;br /&gt;
* Save the code beneath as 't' (without '.txt'), so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
* Change the extension back to .jar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks. There are also some functions that combine default functions for ease of use. E.g. turnAround() turns right twice.&lt;br /&gt;
&amp;lt;br/&amp;gt;Most of the function names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand falls down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. It combines selecting and placing. &lt;br /&gt;
&amp;lt;br/&amp;gt;I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;If there is another block in the way, it will break it, unless it is the same type of block.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;The following function places a row of blocks: &lt;br /&gt;
* t.placeRow(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. The possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeRow(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. &lt;br /&gt;
&amp;lt;br/&amp;gt;This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can change it to turn left twice ;).&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn back again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Download: [http://pastebin.com/0TnEBf2P Robust Turtle API]&lt;br /&gt;
&amp;lt;br/&amp;gt;Save it as 't', without &amp;quot;.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Robust Turtle API by SpeedR&lt;br /&gt;
&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug up for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug down for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place row     e.g. placeRow(up, marble, forward, 15)&lt;br /&gt;
function placeRow(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5369</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5369"/>
				<updated>2013-04-15T08:10:48Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: Changed the digging code and a few minor things. Renamed placeExt to placeRow.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It also strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling, for example, it will not get stopped by mobs, players, sand, or any other block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Go to minecraft/mods/computercraft.zip/lua/rom/apis/turtle (if you are running on a server, only the server needs the file).&lt;br /&gt;
* Save the code beneath as 't' (without '.txt'), so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks. There are also some functions that combine default functions for ease of use. E.g. turnAround() turns right twice.&lt;br /&gt;
&amp;lt;br/&amp;gt;Most of the function names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand falls down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. It combines selecting and placing. &lt;br /&gt;
&amp;lt;br/&amp;gt;I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;If there is another block in the way, it will break it, unless it is the same type of block.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;The following function places a row of blocks: &lt;br /&gt;
* t.placeRow(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. The possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeRow(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. &lt;br /&gt;
&amp;lt;br/&amp;gt;This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can change it to turn left twice ;).&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn back again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Download: [http://pastebin.com/0TnEBf2P Robust Turtle API]&lt;br /&gt;
&amp;lt;br/&amp;gt;Save it as 't', without &amp;quot;.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Robust Turtle API by SpeedR&lt;br /&gt;
&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug up for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  local tries = 0&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
    tries = tries + 1&lt;br /&gt;
    if tries&amp;gt;500 then&lt;br /&gt;
      print(&amp;quot;Error: dug down for too long.&amp;quot;)&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place row     e.g. placeRow(up, marble, forward, 15)&lt;br /&gt;
function placeRow(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Talk:Robust_Turtle_API&amp;diff=5368</id>
		<title>Talk:Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Talk:Robust_Turtle_API&amp;diff=5368"/>
				<updated>2013-04-15T07:42:15Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: /* About digging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About digging ==&lt;br /&gt;
&lt;br /&gt;
You should add a timeout function so that your turtle's problem doesn't stall. If someone has a cobblestone generator for example, and they want it to dig only 128 at a time, your program is going to be frozen. [[User:Unit158|-Unit]] 10:03, 14 April 2013 (MSK)&lt;br /&gt;
&lt;br /&gt;
: Good point. It will not happen often, but the purpose is to be robust so I guess I'll add it. --[[User:Requios|Requios]] 11:42, 15 April 2013 (MSK)&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5362</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5362"/>
				<updated>2013-04-14T03:28:51Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It also strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling for example, it will not get stopped by mobs, players, sand, or any other block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Go to minecraft/mods/computercraft.zip/lua/rom/apis/turtle (if you are running on a server, only the server needs the file).&lt;br /&gt;
* Save the code beneath as 't' (without '.txt'), so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks. There are also some functions that combine default functions for ease of use. E.g. turnAround() turns right twice.&lt;br /&gt;
&amp;lt;br/&amp;gt;Most of the function names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand falls down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; The following is a special function. It is an extended version of the place functions. It places a row of blocks: &lt;br /&gt;
* t.placeExt(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. The possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeExt(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can change it to turn left twice.&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn back again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Download: [http://pastebin.com/D4ysDZLc Robust Turtle API]&lt;br /&gt;
&amp;lt;br/&amp;gt;Save it as 't', without &amp;quot;.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Robust Turtle API by SpeedR&lt;br /&gt;
&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place extended     e.g. placeExt(up, marble, forward, 15)&lt;br /&gt;
function placeExt(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5361</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5361"/>
				<updated>2013-04-14T03:16:16Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It also strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling for example, it will not get stopped by mobs, players, sand, or any other block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Go to minecraft/mods/computercraft.zip/lua/rom/apis/turtle (if you are running on a server, only the server needs the file).&lt;br /&gt;
* Save the code beneath as 't', so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks. There are also some functions that combine default functions for ease of use. E.g. turnAround() turns right twice.&lt;br /&gt;
&amp;lt;br/&amp;gt;Most of the function names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand falls down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; The following is a special function. It is an extended version of the place functions. It places a row of blocks: &lt;br /&gt;
* t.placeExt(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. Possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeExt(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can change it to turn left twice.&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn back again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place extended     e.g. placeExt(up, marble, forward, 15)&lt;br /&gt;
function placeExt(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5360</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5360"/>
				<updated>2013-04-14T03:13:55Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It also strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling for example, it will not get stopped by mobs, players, or any block. Not even sand that comes falling down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Go to minecraft/mods/computercraft.zip/lua/rom/apis/turtle (if you are running on a server, only the server needs the file).&lt;br /&gt;
* Save the code beneath as 't', so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks. There are also some functions that combine default functions for ease of use. E.g. turnAround() turns right twice.&lt;br /&gt;
&amp;lt;br/&amp;gt;Most of the function names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand falls down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; The following is a special function. It is an extended version of the place functions. It places a row of blocks: &lt;br /&gt;
* t.placeExt(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. Possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeExt(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can change it to turn left twice.&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn back again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place extended     e.g. placeExt(up, marble, forward, 15)&lt;br /&gt;
function placeExt(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5359</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5359"/>
				<updated>2013-04-14T03:11:12Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling for example, it will not get stopped by mobs, players, or any block. Not even sand that comes falling down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Go to minecraft/mods/computercraft.zip/lua/rom/apis/turtle (if you are running on a server, only the server needs the file).&lt;br /&gt;
* Save the code beneath as 't', so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks. There are also some functions that combine default functions for ease of use. E.g. turnAround() turns right twice.&lt;br /&gt;
&amp;lt;br/&amp;gt;Most of the function names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand falls down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; The following is a special function. It is an extended version of the place functions. It places a row of blocks: &lt;br /&gt;
* t.placeExt(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. Possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeExt(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can change it to turn left twice.&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn back again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place extended     e.g. placeExt(up, marble, forward, 15)&lt;br /&gt;
function placeExt(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5358</id>
		<title>Robust Turtle API</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Robust_Turtle_API&amp;diff=5358"/>
				<updated>2013-04-14T02:42:34Z</updated>
		
		<summary type="html">&lt;p&gt;Requios: A turtle API that extends on the original turtle API and makes it more robust.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an &amp;lt;b&amp;gt;unofficial API&amp;lt;/b&amp;gt;. This means that you have to install it manually.&lt;br /&gt;
&amp;lt;br/&amp;gt; This API extends on the original turtle API and makes it more robust. It strives to make coding a turtle easier.&lt;br /&gt;
&amp;lt;br/&amp;gt; When traveling, for example, it will not get stopped by mobs, players, or any block. Not even sand that comes falling down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
* Go to minecraft/mods/computercraft.zip/lua/rom/apis/turtle (if you are running on a server, only the server needs to have it).&lt;br /&gt;
* Save the code beneath as 't', so that you can easily call every function in-game, e.g. &amp;quot;t.forward()&amp;quot;.&lt;br /&gt;
* Add the file to the folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Explanation==&lt;br /&gt;
&lt;br /&gt;
A lot of the functions do the same as the default turtle API, except with additional checks.&lt;br /&gt;
&amp;lt;br/&amp;gt;The names are the same, but instead of writing &amp;quot;turtle.&amp;quot; in front, you can now write &amp;quot;t.&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Digging'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will dig as long as there is a block in the way. So if sand comes falling down, it will dig as long as necessary.&lt;br /&gt;
* t.dig()&lt;br /&gt;
* t.digUp()&lt;br /&gt;
* t.digDown()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Traveling'''&lt;br /&gt;
&amp;lt;br/&amp;gt;These will not be stopped by blocks or mobs.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, you can leave it out. It is the amount of blocks to travel. If left out these will travel 1 block.&lt;br /&gt;
* t.forward(''[amount]'')&lt;br /&gt;
* t.up(''[amount]'')&lt;br /&gt;
* t.down(''[amount]'')&lt;br /&gt;
* t.back(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Placing blocks'''&lt;br /&gt;
&amp;lt;br/&amp;gt;Here, '&amp;lt;i&amp;gt;block&amp;lt;/i&amp;gt;' is a number between 1 and 16. I highly recommend adding e.g. &amp;quot;stoneBrick = 1&amp;quot; at the beginning of the code. This way you can later easily see which block must go in which slot. Example: &amp;quot;t.place(stoneBrick)&amp;quot;.&lt;br /&gt;
* t.place(''block'')&lt;br /&gt;
* t.placeUp(''block'')&lt;br /&gt;
* t.placeDown(''block'')&lt;br /&gt;
* t.placeRight(''block'')&lt;br /&gt;
* t.placeLeft(''block'')&lt;br /&gt;
* t.placeBack(''block'')&lt;br /&gt;
If any of these run out of their resource, the API will write a message and waits for any text input to continue. This way you can refill and write something (anything) to continue the program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; The following is a special function. It places a row of blocks: &lt;br /&gt;
* t.placeExt(''placeDir'', ''block'', ''travelDir'', ''length'')&lt;br /&gt;
**''travelDir'' is the most logical one. It is the direction the turtle travels to. Possible directions: &amp;quot;forward&amp;quot;,&amp;quot;up&amp;quot;,&amp;quot;down&amp;quot;,&amp;quot;right&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;back&amp;quot;.&lt;br /&gt;
**''placeDir'' is a bit more difficult to understand. ''placeDir'' is the direction to place the block in. The turtle travels in one direction, but it cannot place a block in that direction (it can, but it will get dug up again). This means that the place direction must be another direction as the travel direction. Possible directions are the same as ''travelDir''.&lt;br /&gt;
**''length'' is the amount of blocks to travel.&lt;br /&gt;
**Example: t.placeExt(up, marble, forward, 15)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;'''Turning'''&lt;br /&gt;
&amp;lt;br/&amp;gt;This function simply turns right twice. If you really want, you can easily change it to turn left twice.&lt;br /&gt;
* t.turnAround()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are simply a shorter way to write turtle.turnLeft() and turtle.turnRight().&lt;br /&gt;
* t.right()&lt;br /&gt;
* t.left()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These simply turn left or right, and move forward an amount.&lt;br /&gt;
&amp;lt;br/&amp;gt;''[amount]'' is optional, and is the amount of blocks to travel forward. If left out these will travel 1 block.&lt;br /&gt;
* t.goRight(''[amount]'')&lt;br /&gt;
* t.goLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;These are the same as the previous functions, except at the end they turn in the opposite direction again.&lt;br /&gt;
* t.strafeRight(''[amount]'')&lt;br /&gt;
* t.strafeLeft(''[amount]'')&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--Digging with gravel/sand detection&lt;br /&gt;
function dig()&lt;br /&gt;
  while turtle.detect() do&lt;br /&gt;
    turtle.dig()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digUp()&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function digDown()&lt;br /&gt;
  while turtle.detectDown() do&lt;br /&gt;
    turtle.digDown()&lt;br /&gt;
    sleep(0.4)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Traveling: Goes in the direction no matter what (almost)&lt;br /&gt;
--Will not be stopped by blocks or mobs&lt;br /&gt;
function forward(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.forward() ~= true do&lt;br /&gt;
      turtle.dig()&lt;br /&gt;
      turtle.attack()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move forward.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function up(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.up() ~= true do&lt;br /&gt;
      turtle.digUp()&lt;br /&gt;
      turtle.attackUp()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move up.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function down(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    local tries = 0&lt;br /&gt;
    while turtle.down() ~= true do&lt;br /&gt;
      turtle.digDown()&lt;br /&gt;
      turtle.attackDown()&lt;br /&gt;
      sleep(0.2)&lt;br /&gt;
      tries = tries + 1&lt;br /&gt;
      if tries&amp;gt;500 then&lt;br /&gt;
        print(&amp;quot;Error: can't move down.&amp;quot;)&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function back(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if turtle.back() ~= true then&lt;br /&gt;
      turnAround()&lt;br /&gt;
      forward()&lt;br /&gt;
      turnAround()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Place blocks&lt;br /&gt;
--Does not place when there's already the right block.&lt;br /&gt;
function place(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compare()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    dig()&lt;br /&gt;
    turtle.place()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeUp(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareUp()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digUp()&lt;br /&gt;
    turtle.placeUp()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeDown(block)&lt;br /&gt;
  turtle.select(block)&lt;br /&gt;
  if turtle.compareDown()==false then&lt;br /&gt;
    if turtle.getItemCount(block)==0 then&lt;br /&gt;
      outOfResource(block)&lt;br /&gt;
    end&lt;br /&gt;
    digDown()&lt;br /&gt;
    turtle.placeDown()&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function outOfResource()&lt;br /&gt;
  print(&amp;quot;Ran out of a resource. Block: &amp;quot;,block , &amp;quot;.&amp;quot;)&lt;br /&gt;
  print(&amp;quot;Refill, then say something to proceed.&amp;quot;)&lt;br /&gt;
  read()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeRight(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeLeft(block)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function placeBack(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
  place(block)&lt;br /&gt;
  turnAround()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--place extended     e.g. placeExt(up, marble, forward, 15)&lt;br /&gt;
function placeExt(placeDir, block, travelDir, l) &lt;br /&gt;
  l=l or 1&lt;br /&gt;
  for i=1,l do&lt;br /&gt;
    if placeDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      place(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      placeUp(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      placeDown(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      placeRight(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      placeLeft(block)&lt;br /&gt;
    elseif placeDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      placeBack(block)&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', placeDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
    if travelDir == &amp;quot;forward&amp;quot; then&lt;br /&gt;
      forward()&lt;br /&gt;
    elseif travelDir == &amp;quot;up&amp;quot; then&lt;br /&gt;
      up()&lt;br /&gt;
    elseif travelDir == &amp;quot;down&amp;quot; then&lt;br /&gt;
      down()&lt;br /&gt;
    elseif travelDir == &amp;quot;right&amp;quot; then&lt;br /&gt;
      strafeRight()&lt;br /&gt;
    elseif travelDir == &amp;quot;left&amp;quot; then&lt;br /&gt;
      strafeLeft()&lt;br /&gt;
    elseif travelDir == &amp;quot;back&amp;quot; then&lt;br /&gt;
      back()&lt;br /&gt;
    else&lt;br /&gt;
      print('&amp;quot;', travelDir, '&amp;quot; is not a valid direction!')&lt;br /&gt;
      return false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--Turning&lt;br /&gt;
function turnAround()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function right()&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function left()&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function goLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
  forward(l)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeRight(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goRight(l)&lt;br /&gt;
  turtle.turnLeft()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function strafeLeft(l)&lt;br /&gt;
  l=l or 1&lt;br /&gt;
  goLeft(l)&lt;br /&gt;
  turtle.turnRight()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unofficial_APIs]]&lt;/div&gt;</summary>
		<author><name>Requios</name></author>	</entry>

	</feed>