Difference between revisions of "Turtle.attack"
From ComputerCraft Wiki
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
{{Function | {{Function | ||
|name=turtle.attack | |name=turtle.attack | ||
|api=turtle | |api=turtle | ||
− | |returns=[[boolean]] whether the turtle succeeded in attacking | + | |returns=[[boolean]] whether the turtle succeeded in attacking forward |
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Attempts to attack the | + | |desc=Attempts to attack in front of the turtle. |
+ | |examples= | ||
+ | {{Example | ||
+ | |desc=Tries to attack in front of the turtle and outputs whether it worked or not. | ||
+ | |code=if turtle.attack() then | ||
+ | [[print]] ("Turtle attacked in front.") | ||
+ | else | ||
+ | [[print]] ("Turtle could not attack.") | ||
+ | end | ||
+ | |output= Turtle attacked in front. or Turtle could not attack. | ||
+ | }} | ||
+ | |||
+ | }} |
Revision as of 12:35, 24 September 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 attacked in front.") else print ("Turtle could not attack.") end |
Output | Turtle attacked in front. or Turtle could not attack. |