Sharp Aion2 Lua SDK
API reference

packetsLua table

Observe packet copies, queue outgoing bodies, and edit future packets.

The packets table is available in Release builds of the updated client. It exposes packet IDs and binary bodies. It does not decode skill IDs, actors, targets, or coordinates for Lua. Use a packet format you have verified for your client before building or editing its body.

The Packets page can capture traffic in Release builds. Its feed shows names and decoded fields for supported formats; other packets show basic information without decoded fields. Lua callbacks receive copied body bytes regardless of whether the feed knows the format.

Packet ID catalog

Browse all 1,578 named packet IDs checked against the current game version: 1,551 Game and 27 Login. Search by packet name, ID, or declared field; filter by connection; then open a packet to see its fields and types. The connection is part of the identity; the same numeric ID can mean different packets on Game and Login.

The declared field lists come from the accepted November 26, 2026 SDK snapshot for all 1,578 packets. These declarations describe game data types, not the bytes or field order sent over the connection.

For 19 packets, a separate section shows fields and encodings traced from an earlier analyzed game version. The other packets have no confirmed wire layout here. IDs and formats can change between versions; verify a format for your game version before using packets.craft, packets.send, or packets.edit.

Loading packet IDs…

Download the complete name and ID list as JSON.

Receive packet copies

packets.on_receive(fn)

Parameters: fn is a module callback receiving (opcode, data, packet). Pass nil to remove the callback. This call requires a loaded module.

Returns: true when the callback is set or removed, or nil, error for invalid input.

The callback runs on a later script update for incoming packets. opcode is the numeric packet ID. data is a copied binary body of at most 4096 bytes, including any zero bytes. packet.body contains the same copy. The packet table also contains:

FieldMeaning
idNumeric packet ID.
server1 for Game or 2 for Login.
direction0 for incoming or 1 for outgoing. This callback receives incoming packets.
body_sizeOriginal body size in bytes.
truncatedtrue when the body exceeded the copied data.
droppedCount of packet observations lost before this callback.
bodyCopied binary body, at most 4096 bytes.

Changing data or the packet table does not change the packet currently being processed. A module can also use on_packet(packet) to receive observed packet copies; that callback may include outgoing traffic when it is being observed.

function on_start()
    local ok, err = packets.on_receive(function(opcode, data, packet)
        log.info(string.format("RX %04X: %d bytes", opcode, packet.body_size))
        if packet.truncated then log.warn("Packet body copy was shortened") end
    end)
    if not ok then log.warn(err) end
end

Build and queue packets

packets.craft(protocol, body)

Parameters: protocol is an integer from 1 to 65535. body is a binary string of at most 4096 bytes.

Returns: { id = protocol, body = body }, or nil, error for invalid input. This validates and groups the values; it does not encode fields or queue a request. Use Lua string.pack only when you know the packet's field layout.

local function buildKnownPacket(protocol, body)
    local packet, err = packets.craft(protocol, body)
    if not packet then return nil, err end
    return packet
end

packets.send(protocol, body)

The same call also accepts a crafted packet table: packets.send(packet).

Parameters: Use the same ID and body limits as packets.craft. Sending requires an available local world and character. The body is queued for the Game connection and is consumed after the next outgoing enqueue; a pending request expires after five seconds.

Returns: true when queued, or nil, error if the request cannot be queued. A successful result does not confirm delivery or game response.

local function queueKnownPacket(protocol, body)
    local packet, err = packets.craft(protocol, body)
    if not packet then return nil, err end
    return packets.send(packet)
end

Edit later packets

packets.edit(protocol, direction, byteIndex, expected, replacement, server)

Parameters: protocol is an integer from 1 to 65535. direction is "rx" or "incoming" for received packets, or "tx" or "outgoing" for sent packets. byteIndex is a zero-based position in the body. expected is a binary string of 1 to 64 bytes, and replacement must have the same length. The optional server is "game" by default or "login". This call requires a loaded module.

Returns: A numeric rule ID, or nil, error. A module can have at most 16 rules; the total limit is 64. A rule applies only to future matching packets with bodies of at most 4096 bytes. The bytes at the selected position must exactly match expected before they are replaced. The replacement cannot change body length and does not recalculate other fields or checksums.

Rules run before packet handling. Registering a rule inside packets.on_receive therefore affects later packets, not the packet that triggered the callback.

local function replaceKnownByte(protocol, byteIndex, oldByte, newByte)
    return packets.edit(protocol, "rx", byteIndex, oldByte, newByte, "game")
end

packets.unedit(ruleId)

Parameters: ruleId is an ID returned by packets.edit. A module can remove only its own rules.

Returns: true when removed, false when the ID was not present, or nil, error for invalid input. Rules are also cleared when the module unloads, restarts, faults, or the scripting runtime shuts down.

local function removeKnownRule(ruleId)
    return packets.unedit(ruleId)
end

On this page