Difference between revisions of "Turtle.attack"

From ComputerCraft Wiki
Jump to: navigation, search
(Corrected mapping from "Boolean" to "Boolean (type)")
(Adding "see also".)
Line 17: Line 17:
  
 
}}
 
}}
 +
 +
==See also==
 +
*[[turtle.attackUp]]
 +
*[[turtle.attackDown]]
  
 
[[Category:Lua_Core_Functions]]
 
[[Category:Lua_Core_Functions]]

Revision as of 16:07, 24 April 2015

Grid Redstone.png  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

Grid paper.png  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.


See also