Difference between revisions of "Turtle.attack"
From ComputerCraft Wiki
Line 9: | Line 9: | ||
|desc=Tries to attack in front of the turtle and outputs whether it worked or not. | |desc=Tries to attack in front of the turtle and outputs whether it worked or not. | ||
|code=if turtle.attack() then | |code=if turtle.attack() then | ||
− | [[print]] ("Turtle | + | [[print]] ("Turtle died.") |
else | else | ||
− | [[print]] ("Turtle | + | [[print]] ("Turtle blew up.") |
end | end | ||
|output= Turtle attacked in front. or Turtle could not attack. | |output= Turtle attacked in front. or Turtle could not attack. |
Revision as of 06:34, 6 November 2012
Function turtle.attack | |
Attempts to attack in front of the turtle. | |
Syntax | turtle.attack() |
Returns | boolean whether the turtle succeeded in attacking forward |
Part of | ComputerCraft |
API | turtle |
Examples
Example | |
Tries to attack in front of the turtle and outputs whether it worked or not. | |
Code |
if turtle.attack() then print ("Turtle died.") else print ("Turtle blew up.") end |
Output | Turtle attacked in front. or Turtle could not attack. |