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.
| Fields | Type and meaning |
|---|---|
object | Opaque, short-lived record token; do not save or manipulate it |
id, uid | Integer identity values; neither is a skill or item ID |
x, y, z | Integer world coordinates; use the position helper for fractional coordinates |
normal_x, normal_y, normal_z | Integer orientation values; not a normalized floating-point vector |
current_hp, maximum_hp, health_percent | Integer health values and percentage |
current_mp, maximum_mp | Integer mana values |
level, class_id, combat_power, experience | Integer progression values; do not equate class_id with the simpler class helper's codes |
distance, skill_id, state, movement_state | Integer distance, current skill, and state values |
dead, in_combat, interacting, moving_to_interact | Integer state indicators, not Lua booleans; zero is false |
gathering_attempts_left, interactor_count | Integer interaction counters |
target_uid, hate_uid | Integer target and hostility identity values; do not substitute them for a target key without establishing the identity domain |
race, entity_type | Integer category codes |
flight_power_percent, current_flight_power, maximum_flight_power | Integer flight resource values |
stamina_percent, current_stamina, maximum_stamina | Integer action-resource values |
class_name | Nonempty 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
endgame._tagged_character_resources()
No arguments. Returns eight integer fields or nil, error:
| Resource | Current field | Maximum field |
|---|---|---|
| Health | current_health | maximum_health |
| Mana | current_mana | maximum_mana |
| Stamina | current_stamina | maximum_stamina |
| Flight power | current_flight_power | maximum_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.
| Fields | Meaning |
|---|---|
obj, id, uid | Opaque record token, template ID, and entity identity; keep their domains separate |
x, y, z, distance | Integer world position and distance |
normal_x, normal_y, normal_z | Integer orientation values |
current_hp, max_hp, hp_percent, current_mp, max_mp | Integer resource values |
combat_power, level, experience, class_id, class_name | Progression and category information |
skill_id, target_uid, hate_uid | Current skill and target-related values |
type, race, state, dead, in_combat, movement_state | Integer categories and state indicators |
interaction_state, interaction_route, remaining_gather_count, current_interactor_count | Interaction values and counters |
action_ratio, current_action, max_action | Integer action-resource values |
flight_ratio, current_flight, max_flight | Integer 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
endgame._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