Difference between revisions of "VectorA:add"

From ComputerCraft Wiki
Jump to: navigation, search
 
Line 6: Line 6:
 
|api=vector
 
|api=vector
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=Returns the result of two vectors
+
|desc=Adds the two vectors and returns the resulting vector.
 
|examples=
 
|examples=
 
{{Example
 
{{Example

Latest revision as of 11:58, 23 February 2013


Grid Redstone.png  Function vector:add
Adds the two vectors and returns the resulting vector.
Syntax vector:add(vector vect)
Returns vector
Part of ComputerCraft
API vector

Examples

Grid paper.png  Example
Creates two vectors, adds them, and then prints the resulting vector
Code
local a = vector.new(1, 2, 3)
local b = vector.new(4, 5, 6)

local c = a:add(b)
--local c = a + b

print(c.x)
print(c.y)
print(c.z)
--5
--7
--9