vectorA:add

From ComputerCraft Wiki
Jump to: navigation, search


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