Difference between revisions of "Turtle.inspect"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "{{lowercase}} {{Function |name=turtle.inspect |args=[<nowiki/>{{type|number}} slotNum] |api=turtle |returns={{type|boolean}} success, {{type|table}} data/{{type|string}} error...")
 
([facepalm] derp, this function doesn't take any arguments)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=turtle.inspect
 
|name=turtle.inspect
|args=[<nowiki/>{{type|number}} slotNum]
+
|args=
 
|api=turtle
 
|api=turtle
 
|returns={{type|boolean}} success, {{type|table}} data/{{type|string}} error message
 
|returns={{type|boolean}} success, {{type|table}} data/{{type|string}} error message

Revision as of 23:18, 27 September 2014


Grid Redstone.png  Function turtle.inspect
Returns the ID string and metadata of the block in front of the Turtle in a table format: { name = "modname:blockname", metadata = 0 }.
Syntax turtle.inspect()
Returns boolean success, table data/string error message
Part of ComputerCraft
API turtle

Examples

Grid paper.png  Example
If there is a block in front of the turtle, prints it's name and metadata.
Code
local success, data = turtle.inspect()

if success then
  print("Block name: ", data.name)
  print("Block metadata: ", data.metadata)
end

Additional Notes

  • Returns false when there is nothing (air) in front of the Turtle.