Dev - Data Types - Vector
Vectors are sets of N float-values. Most commonly used to represent positions and scales. There's Vector2, Vector3 and Vector4 which are only different in the number of values N (2, 3 and 4).
Vector Parameters
When methods have vector parameters you can specify them in two different ways:
-
Table
of N numbers. The table keys must either be numbers from 1 to N or omitted. The values must be the vector values:
1
2
3
4
5scale = {}
scale[1] = 1.0
scale[2] = 2.0
scale[3] = 3.0
entity.setScale(1, scale)The same can be done in a single line:
1entity.setScale(1, {1 = 1.0, 2 = 2.0, 3 = 3.0}It is also possible and recommended to completely ommit the keys:
1entity.setScale(1, {1.0, 2.0, 3.0}) -
Number
All vector values will have the same value:
1
2
3entity.setScale(1, 1.0)
-- is the same as:
-- entity.setScale(1, {1.0, 1.0, 1.0})
Vector Return Values
When a method returns a vector, it will be a tuple of N numbers.
Vector2
A vector with 2 values (N=2). Often used for 2D positions or scales. Sample declaration:
Vector3
A vector with 3 values (N=3). Often used for positions, scales or rotations (Euler angles) in 3D. Sample declaration:
Vector4
A vector with 4 values (N=4). Sample declaration: