Difference between revisions of "VectorA:sub"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "Returns the result of subtracting the second vector from the first local a = vector.new(1, 2, 3) local b = vector.new(3, 2, 1) local c = a:sub(b) print(c.x) print(c....")
 
Line 1: Line 1:
Returns the result of subtracting the second vector from the first
+
{{lowercase}}
 
+
{{Function
local a = vector.new(1, 2, 3)
+
|name=vector:sub
 +
|args=[[vector (API)|vector]] vect
 +
|returns=[[vector (API)|vector]]
 +
|api=vector
 +
|addon=ComputerCraft
 +
|desc=Subtracts two vectors and returns the result
 +
|examples=
 +
{{Example
 +
|desc=Subtracts two vectors and prints the resulting components
 +
|code=local a = vector.new(1, 2, 3)
 
  local b = vector.new(3, 2, 1)
 
  local b = vector.new(3, 2, 1)
 
   
 
   
Line 12: Line 21:
 
  --0
 
  --0
 
  --2
 
  --2
 +
}}
 +
}}
 +
 +
[[Category:API_Functions]]

Revision as of 11:50, 23 February 2013


Grid Redstone.png  Function vector:sub
Subtracts two vectors and returns the result
Syntax vector:sub(vector vect)
Returns vector
Part of ComputerCraft
API vector

Examples

Grid paper.png  Example
Subtracts two vectors and prints the resulting components
Code
local a = vector.new(1, 2, 3)
local b = vector.new(3, 2, 1)

local c = a:sub(b)

print(c.x)
print(c.y)
print(c.z)
--(-2)
--0
--2