Sharp Aion2 Lua SDK
API reference

gfxLua table

Draw lines, rectangles, and text on the game screen.

Call gfx functions from a loaded module's on_tick callback. Coordinates are screen positions. Colors use 0xAABBGGRR. A script can submit at most 1024 drawings per update.

gfx.line(x1, y1, x2, y2, color, thickness)

Parameters: The two endpoint pairs are screen coordinates, color is packed color, and optional thickness is greater than 0 and at most 32. Returns: No value on success, or nil, error.

function on_tick()
    gfx.line(20, 20, 120, 20, 0xFFFFFFFF, 2)
end

gfx.rect(x1, y1, x2, y2, color)

Parameters: The first pair is the upper-left corner, the second is the lower-right corner, and color is packed color. Returns: No value on success, or nil, error.

function on_tick()
    gfx.rect(20, 30, 120, 80, 0xFF4080C0)
end

gfx.text(x, y, text, color, size)

Parameters: x and y are screen coordinates; text is at most 512 bytes; color is packed color; optional size is 6–72 (default 16). Returns: No value on success, or nil, error.

function on_tick()
    local level = game.local_level()
    if level then
        gfx.text(20, 80, "Level " .. level, 0xFFFFFFFF, 16)
    end
end

World positions and ground outlines

game.project_position(x, y, z)

game.project_position(x, y, z) converts any finite Unreal world position to screen x, y using the current camera. It returns nil, error when the camera is unavailable or the point is behind it. It does not require an actor.

The ground helpers draw outlines in world units. Circle and cone use a horizontal plane at the supplied z; polygon connects each point at its own z. They project each edge through the current camera and skip edges whose endpoints cannot be projected. They do not sample terrain height or draw filled shapes. Colors use 0xAABBGGRR; optional thickness defaults to 1 and must be greater than 0 and at most 32. Each edge counts toward the 1024 drawing commands per update.

gfx.ground_circle(x, y, z, radius, color, segments, thickness)

Draw a closed circle. radius is greater than 0 and at most 100000 world units. Optional segments defaults to 48 and is 3–128.

gfx.ground_cone(x, y, z, radius, yaw, angle, color, segments, thickness)

Draw a sector outline. yaw is the center direction in degrees from world +X toward +Y; angle is its sweep in degrees (greater than 0 and at most 360). Optional segments defaults to 32 and is 3–128.

gfx.ground_polygon(points, color, thickness)

Draw a closed outline of 3–128 {x, y, z} points in world coordinates.

These functions return no value on success, or nil, error for invalid inputs or when the draw command limit would be exceeded.

function on_tick()
    local position = game.local_position()
    if not position then return end

    gfx.ground_circle(position.x, position.y, position.z, 500, 0xFF00FF00)
    gfx.ground_cone(position.x, position.y, position.z, 700, 90, 60, 0xFF0080FF)
    gfx.ground_polygon({
        {x = position.x, y = position.y, z = position.z},
        {x = position.x + 300, y = position.y, z = position.z},
        {x = position.x, y = position.y + 300, z = position.z},
    }, 0xFFFFFFFF)
end

On this page