From ComputerCraft Wiki
Jump to: navigation, search
Grid Redstone.png  Function turtle.attack
Attempts to attack in front of the turtle. You can pass optionally pass in "left" or "right" to the toolSide argument to determine which tool to attack with, otherwise the turtle will attempt to attack with both tools.
Syntax turtle.attack([string toolSide])
Returns boolean whether the turtle succeeded in attacking forward
Part of ComputerCraft
API turtle


Grid paper.png  Example
Tries to attack in front of the turtle and outputs whether it worked or not.
if turtle.attack() then
 print ("Turtle attacked in front.")
 print ("Turtle could not attack.")
Output Turtle attacked in front. or Turtle could not attack.

See also