Point Type
Point
Represents a 2D point with x and y coordinates, typically used for screen coordinates.
Fields
| Field | Type | Description |
|---|---|---|
| x | number | X coordinate |
| y | number | Y coordinate |
Methods
distance_to(other)
Calculate distance to another point.
Parameters:
| Name | Type | Description |
|---|---|---|
| other | Point | The other point |
Returns: number - The Euclidean distance
Example:
local p1 = {x = 100, y = 100}
local p2 = {x = 200, y = 200}
local dist = p1:distance_to(p2)
print("Distance:", dist) -- ~141.42
Usage
Points are typically used for screen coordinates returned by entity methods:
local player = players:local_player()
local x, y = player:base_point()
print(string.format("Player screen position: (%d, %d)", x, y))