Difference between revisions of "Computer.getID"

From ComputerCraft Wiki
Jump to: navigation, search
m (Changed int to number)
(Variable renaming)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{Lowercase}}
 
{{Function
 
{{Function
|name=computer.getID
+
|name=''computer''.getID
|api=peripheral
+
|api=peripheral
|returns=[[number (type)|number]] ID
+
|returns={{type|number}} computerID
|addon=ComputerCraft
+
|addon=ComputerCraft
|desc=Returns the ID of a computer or turtle wrapped to the "computer" variable
+
|desc=Returns the ID of a [[Computer]] or [[Turtle]] wrapped to the <var>computer</var> variable.
|examples={{Example
+
|examples={{Example
|desc=Prints the ID of a computer or turtle on the right side of the calling machine.
+
|desc=Prints the ID of a computer or turtle on the right side of the calling machine.
|code=
+
|code=
  local handle = peripheral.wrap("right")  
+
local computer = [[peripheral.wrap]]("right")
  print(handle.getID())
+
   
|output=The ID of any computer or turtle to the right of the calling machine.
+
[[print]]('''computer.getID()''')
 +
|output=The ID of any computer or turtle to the right of the calling machine.
 
}}
 
}}
 
}}
 
}}
  
 
[[Category:Lua_Core_Functions]]
 
[[Category:Lua_Core_Functions]]

Latest revision as of 11:03, 1 June 2014


Grid Redstone.png  Function computer.getID
Returns the ID of a Computer or Turtle wrapped to the computer variable.
Syntax computer.getID()
Returns number computerID
Part of ComputerCraft
API peripheral

Examples

Grid paper.png  Example
Prints the ID of a computer or turtle on the right side of the calling machine.
Code
local computer = peripheral.wrap("right")

print(computer.getID())
Output The ID of any computer or turtle to the right of the calling machine.