Sharp Aion2 Lua SDK
API reference

Character and environmentLua table

Detailed character resources, action state, and surrounding entity snapshots.

These advanced functions expose detailed gameplay records. Their underscore-prefixed names are the actual callable names, not alternative spellings. They are experimental: check that a function exists in the installed runtime and handle nil, error. Availability is not a guarantee that every field has the same meaning for every entity type.

Use the simpler character helpers when a name, level, position, or displayed health is sufficient. Combat covers skills and targeting; inventory covers items and gathering.

Character state

game._char_session_present()

No arguments. Returns true when a character session exists, false when it is known to be absent, or nil, error when the check is unavailable. A session alone does not mean the character is able to move or use skills.

game._local_character_id()

No arguments. Returns the current character-session identity as a signed 64-bit Lua integer, or nil, error. Large identities can appear negative. This value is not a character class, template ID, or targeting key. Do not assume it is interchangeable with uid from another record.

game._character_record_candidate()

No arguments. Returns a character table or nil, error. Fields are included only when available; a returned table can be incomplete. Check each field you need instead of substituting zero for a missing field.

FieldsType and meaning
objectOpaque, short-lived record token; do not save or manipulate it
id, uidInteger identity values; neither is a skill or item ID
x, y, zInteger world coordinates; use the position helper for fractional coordinates
normal_x, normal_y, normal_zInteger orientation values; not a normalized floating-point vector
current_hp, maximum_hp, health_percentInteger health values and percentage
current_mp, maximum_mpInteger mana values
level, class_id, combat_power, experienceInteger progression values; do not equate class_id with the simpler class helper's codes
distance, skill_id, state, movement_stateInteger distance, current skill, and state values
dead, in_combat, interacting, moving_to_interactInteger state indicators, not Lua booleans; zero is false
gathering_attempts_left, interactor_countInteger interaction counters
target_uid, hate_uidInteger target and hostility identity values; do not substitute them for a target key without establishing the identity domain
race, entity_typeInteger category codes
flight_power_percent, current_flight_power, maximum_flight_powerInteger flight resource values
stamina_percent, current_stamina, maximum_staminaInteger action-resource values
class_nameNonempty string when available

Do not treat unknown state/category codes as a documented enumeration. All numeric fields above are integers. A missing field differs from a present zero.

function on_start()
    if type(game._character_record_candidate) ~= "function" then
        log.warn("Detailed character data is unavailable")
        return
    end
    local record, err = game._character_record_candidate()
    if not record then
        log.warn(err)
    elseif record.in_combat ~= nil then
        log.info(record.in_combat ~= 0 and "In combat" or "Out of combat")
    end
end

game._tagged_character_resources()

No arguments. Returns eight integer fields or nil, error:

ResourceCurrent fieldMaximum field
Healthcurrent_healthmaximum_health
Manacurrent_manamaximum_mana
Staminacurrent_staminamaximum_stamina
Flight powercurrent_flight_powermaximum_flight_power

Check that a maximum is positive before dividing. These numeric values are distinct from displayed HUD text. Also available through the existing sdk._tagged_character_resources() facade.

game._loot_state_word()

No arguments. Returns an integer from 0 through 65535, or nil, error. It is an uninterpreted loot-state value, not a count of lootable items or a boolean. There is no documented mapping from its values to a completed loot action.

Surrounding entities

game._environment_records()

No arguments. Returns {world_id, source_count, unsupported_count, skipped_count, complete, records} or nil, error. The first four fields are integers, complete is a boolean, and records is an ordered array.

world_id is an opaque session identity for comparing captures, not a map ID. Never persist it. source_count describes the inspected collection; it need not equal #records. If complete is false, unsupported or skipped rows may make the collection unsuitable for decisions requiring a full census. A successful call does not imply completeness.

Every row has the following fields. All are integers except class_name, which is a string. A field can be zero or empty for an entity category that does not supply that value.

FieldsMeaning
obj, id, uidOpaque record token, template ID, and entity identity; keep their domains separate
x, y, z, distanceInteger world position and distance
normal_x, normal_y, normal_zInteger orientation values
current_hp, max_hp, hp_percent, current_mp, max_mpInteger resource values
combat_power, level, experience, class_id, class_nameProgression and category information
skill_id, target_uid, hate_uidCurrent skill and target-related values
type, race, state, dead, in_combat, movement_stateInteger categories and state indicators
interaction_state, interaction_route, remaining_gather_count, current_interactor_countInteraction values and counters
action_ratio, current_action, max_actionInteger action-resource values
flight_ratio, current_flight, max_flightInteger flight-resource values

This schema deliberately differs from the local character schema: for example max_hp versus maximum_hp, and obj versus object. Reacquire rows after changing area, loading a character, or yielding before an action. Do not assume an entity UID can be passed directly to every targeting function. See targeting.

game._environment_records_pair()

No arguments. Returns two consecutive snapshots in the same shape as the function above. On failure, returns nil, nil, error, not the usual two-result error form. Compare session identity, completeness, and entity values before using the pair; identical captures do not guarantee that the world cannot change afterward.

function on_start()
    if type(game._environment_records_pair) ~= "function" then
        return
    end
    local first, second, err = game._environment_records_pair()
    if not first or not second then
        log.warn(err)
        return
    end
    if first.complete and second.complete and first.world_id == second.world_id then
        log.info(string.format("Captured %d then %d rows",
            #first.records, #second.records))
    end
end

game._nearby_character_actions(radius [, record_ids])

A bounded reader for what nearby characters are doing. radius is centimeters around your character (horizontal), greater than 0 and at most 10000. record_ids is an optional set of character record ids ({[2090027] = true}); when given, only those characters are read in full. Returns rows, truncated or nil, error. Each row is {obj, id, uid, skill_id, dead, current_hp, x, y, z} with the same meanings as the environment record fields of the same name. At most 64 rows are returned; truncated is true when more matched.

The full environment capture also reads names, class text and interaction objects for every actor, which costs tens of milliseconds per call in a crowded area. Use this reader when only skill, death state and position are needed, for example to watch boss actions several times a second. It is available on clients built after October 29, 2026; check type(game._nearby_character_actions).

local bosses = {[2090027] = true}
local rows = game._nearby_character_actions(2500, bosses)
for _, row in ipairs(rows or {}) do
    if row.dead == 0 and row.skill_id ~= 0 then
        log.info("boss " .. row.id .. " uses skill " .. row.skill_id)
    end
end

On this page