Vector2 & Vector2i
Two coordinate primitives the bot passes around for any spatial argument:
Vector2— float-precision world position (sub-tile resolution, e.g.client:position()).Vector2i— integer tile point (e.g.client:point(),world:tile(point)).
Tile size is 0.32 world units, so world ↔ tile round-trips through that constant.
local point = Vector2i.new(5, 5)
local position = Vector2.new(5.3, 8.7)
Constructors
Vector2.new(x, y)
| Field | Type |
|---|---|
| Signature | (x: number, y: number) → Vec2 |
| Returns | Vec2 — float-precision world-unit point |
| Async | no |
Vector2i.new(x, y)
| Field | Type |
|---|---|
| Signature | (x: number, y: number) → Vec2i |
| Returns | Vec2i — integer tile-coord point |
| Async | no |
local entitySize = Vector2.new(0.32, 0.32)
local tile = Vector2i.new(5, 5)
Fields
vec.x / vec.y
| Field | Type |
|---|---|
| Signature | Vec2.x → number / Vec2.y → number (read + write, both axes) |
| Returns | number — float for Vec2, integer for Vec2i |
Both axes are mutable — write back to update the value in place.
local p = Vector2i.new(5, 5)
p.x -- 5
p.y -- 5
p.x = p.x + 1
Methods
Vec2:point(size)
| Field | Type |
|---|---|
| Signature | (self: Vec2, size: Vec2) → Vec2i |
| Returns | Vec2i — tile point of an entity of size whose top-left corner sits at this world position |
| Async | no |
Vec2i:position(size)
| Field | Type |
|---|---|
| Signature | (self: Vec2i, size: Vec2) → Vec2 |
| Returns | Vec2 — world-space top-left corner of an entity of size placed at this tile point |
| Async | no |
Vec2:point and Vec2i:position round-trip through TILE_SIZE = 0.32 and the half-tile center offset, so tile:position(size):point(size) returns the original tile.
local entitySize = Vector2.new(0.32, 0.32)
local point = Vector2i.new(5, 5)
point:position(entitySize) -- world position scaled to the entity size
local position = Vector2.new(5.3, 8.7)
position:point(entitySize) -- nearest tile point at that entity size
Vec2:equals(other) / Vec2i:equals(other)
| Field | Type |
|---|---|
| Signature | (self: Vec2, other: Vec2) → boolean (and the Vec2i variant) |
| Returns | boolean — true when both x and y match exactly |
| Async | no |
Both types also implement the == metamethod, so a == b and a:equals(b) are interchangeable.
Vector2i.new(5, 5):equals(Vector2i.new(5, 5)) -- true
Vector2.new(1.0, 2.0) == Vector2.new(1.0, 2.0) -- true
Mostly used to feed client:setPoint, client:findPath, world:tile, client:hit, etc.