Difference between revisions of "Turtle.attack"

From ComputerCraft Wiki
Jump to: navigation, search
Line 2: Line 2:
 
'''This page is currently unfinished.'''
 
'''This page is currently unfinished.'''
 
----
 
----
This command attacks any entity that is one block in front of the turtle.
+
{{Function
 +
|name=turtle.attack
 +
|api=turtle
 +
|returns=[[boolean]] whether the turtle succeeded in attacking
 +
|addon=ComputerCraft
 +
|desc=Attempts to attack the block in front.
 +
|examples=
 +
{{Example
 +
|desc=Tries to attack a mob/player in front 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:30, 24 September 2012

This page is a stub.
Please help us by expanding it.

This page is currently unfinished.


{{Function |name=turtle.attack |api=turtle |returns=boolean whether the turtle succeeded in attacking |addon=ComputerCraft |desc=Attempts to attack the block in front. |examples=

Grid paper.png  Example
Tries to attack a mob/player in front 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.