vec4¶
Source: base/tealdef/scripts/vec4.d.tl
Notes
Types of the plain-Lua 4D vector library /scripts/vec4.tl (Vec4Serialized); mat4 uses these
vectors as matrix columns. Load it with local vec4 = ug_require "/scripts/vec4.tl" as Vec4Serialized.
Vec4iSerialized¶
record global base/tealdef/scripts/vec4.d.tl:3
global record Vec4iSerialized
Notes
Namespace of the integer 4D vector type Vec4i.
Vec4iSerialized.Vec4i¶
record base/tealdef/scripts/vec4.d.tl:4
record Vec4i
Notes
4D vector with integer components, as a plain table {x = ..., y = ..., z = ..., w = ...}.
Fields
| Name | Type | Description |
|---|---|---|
x |
integer |
X component. |
y |
integer |
Y component. |
z |
integer |
Z component. |
w |
integer |
W component. |
Vec4Serialized¶
record global base/tealdef/scripts/vec4.d.tl:12
global record Vec4Serialized
Load: local vec4 = require "/scripts/vec4.tl"
Notes
The 4D vector library returned by ug_require "/scripts/vec4.tl", and the namespace of its Vec4 type.
Functions
new(x : number, y : number, z : number, w : number) : Vec4 base/tealdef/scripts/vec4.d.tl:27
Call as vec4.new
Notes
Creates a 4D vector with arithmetic operators attached.
| Parameter | Type | Description |
|---|---|---|
x |
number |
X component. |
y |
number |
Y component. |
z |
number |
Z component. |
w |
number |
W component. |
Returns Vec4: The new vector.
Used in the base game: 94 times in 4 files
base/content/stations/air/air/airport/airport_modules.script.lua:16
base/content/stations/water/water/modules.script.lua:843
base/content/stations/street/street/modular_street_station/modules.script.lua:105
base/content/scripts/scripts/mat4.tl:10
add(v1 : Vec4, v2 : Vec4) : Vec4 base/tealdef/scripts/vec4.d.tl:29
Call as vec4.add
Notes
Returns v1 + v2.
Returns Vec4
sub(v1 : Vec4, v2 : Vec4) : Vec4 base/tealdef/scripts/vec4.d.tl:30
Call as vec4.sub
Notes
Returns v1 - v2.
Returns Vec4
mul(f : number, v : Vec4) : Vec4 base/tealdef/scripts/vec4.d.tl:31
Call as vec4.mul
Notes
Returns the vector v scaled by the number f.
Returns Vec4
div(v : Vec4, d : number) : Vec4 base/tealdef/scripts/vec4.d.tl:32
Call as vec4.div
Notes
Returns the vector v with each component divided by d.
Returns Vec4
toArray(v : Vec4) : Table4 base/tealdef/scripts/vec4.d.tl:37
Call as vec4.toArray
Convert vector to an array of four numbers.
| Parameter | Type | Description |
|---|---|---|
v |
Vec4 |
vector |
Returns Table4: array with x, y, z, w components
fromArray(t : Table4) : Vec4 base/tealdef/scripts/vec4.d.tl:41
Call as vec4.fromArray
Create vector from an array of four numbers.
| Parameter | Type | Description |
|---|---|---|
t |
Table4 |
array with x, y, z, w components |
Returns Vec4: vector
print(v : Vec4) : string base/tealdef/scripts/vec4.d.tl:46
Call as vec4.print
Convert vector to a string representation.
| Parameter | Type | Description |
|---|---|---|
v |
Vec4 |
vector |
Returns string: string representation
Vec4Serialized.Table4¶
record base/tealdef/scripts/vec4.d.tl:13
record Table4 is {number}
of lenght 4
Used in the base game: 2 times in 1 file
base/content/scripts/scripts/vec4.tl:32
Vec4Serialized.Vec4¶
record base/tealdef/scripts/vec4.d.tl:15
record Vec4
Notes
4D vector as a plain table {x = ..., y = ..., z = ..., w = ...} with arithmetic operators. mat4.new
takes four of them as matrix columns.
Used in the base game: 32 times in 2 files
base/content/scripts/scripts/vec4.tl:3
base/content/scripts/scripts/mat4.tl:6
Fields
| Name | Type | Description |
|---|---|---|
x |
number |
X component. |
y |
number |
Y component. |
z |
number |
Z component. |
w |
number |
W component (1 for points and 0 for directions when used with mat4.gemv). |
Functions
metamethod __add(v1 : Vec4, v2 : Vec4) : Vec4 base/tealdef/scripts/vec4.d.tl:21
Notes
Component-wise sum v1 + v2.
Returns Vec4
metamethod __sub(v1 : Vec4, v2 : Vec4) : Vec4 base/tealdef/scripts/vec4.d.tl:22
Notes
Component-wise difference v1 - v2.
Returns Vec4