Basics

Vec2, Vec3 and Color

The value types used for positions, sizes and colors.

Positions and sizes are Vec2 (screen) and Vec3 (world) values, and colors are Color values. All three have fields you can read and assign, methods, operators and tostring.

local a = Vec3(100, 200, 0)
local b = a + Vec3(0, 0, 50) * 2
print(b, a:distance(b))          --> Vec3(100.000, 200.000, 100.000)  100.0

local c = Color.hex("#4FC3F7")
c.a = 128
print(c)                         --> Color(79, 195, 247, 128)

Any function that takes one of these also takes a plain table: {x = 1, y = 2} or {1, 2} for a Vec2, {r = 255, g = 0, b = 0} or {255, 0, 0} for a Color. Where a function takes a 3D position, an Agent works too and stands for where the agent is.

Vec2

A 2D vector. Vec2.new(x, y) does the same. Missing components are 0.
v.x, v.ynumber
The components. They can be assigned.
Component by component. Either side can be a number: v * 2, 2 * v.
a == bboolean
True when both are Vec2 values with the same components.
The vector's length.
The same direction with length 1 (a zero vector stays zero).
The dot product.
The distance between two points.
The point t of the way from v to other (0 is v, 1 is other).
A copy.
The components as two numbers.
A Vec3 with this x and y, and z (0 by default).

Vec3

Everything Vec2 has, in three components, plus:

A 3D vector. Vec3.new(x, y, z) does the same.
The length of x and y only, ignoring height.
The distance on the ground, ignoring height.
The cross product.
v:xy()Vec2
The x and y components.
Whether something at pos turned to rotation (as agent:rotation() returns) faces target, within max_angle.

Color

Components are integers from 0 to 255. Values outside that range are clamped.

A color; alpha is 255 (opaque) by default. Color.new and Color.rgb(r, g, b) do the same.
A color from components between 0 and 1.
From a string, "#RGB", "#RGBA", "#RRGGBB" or "#RRGGBBAA" (the # is optional), or from a number, 0xRRGGBB, with alpha as a separate argument (255 by default).
The components. They can be assigned.
A copy with another alpha.
A mix: t of the way from c to other.
A copy.
c:unpack()r, g, b, a
The components as four integers.
c:to_floats()r, g, b, a
The components as four numbers between 0 and 1.
Color constants
REDGREENBLUEWHITEBLACKYELLOWCYANMAGENTAGRAYORANGETRANSPARENT

Each use of a constant such as Color.RED is a fresh value, so changing it never changes the constant.