gameLua table
Read character and world values, and request game actions.
The game table is available in every script. This page covers its common character, entity, travel, shortcut, and quest functions. The sdk library exports a subset of game calls alongside shared Lua helpers; not every game function has an sdk alias.
Detailed gameplay references cover combat and skills, character and environment, inventory and crafting, quests, dungeons, and rewards, commerce, navigation and camera, and game windows and controls. Those advanced calls use their exact underscore-prefixed names where shown and may be unavailable in an older installed runtime.
Values that require a logged-in character or loaded world return nil, error while unavailable. A successful action reports a local request, not a completed movement, consumed item, activated skill, or completed quest. Read the relevant value on a later tick to see the result. See callback timing and errors and limits.
| Working with | Start here | Complete example |
|---|---|---|
| Character data | Position and resources | Starter scripts |
| Nearby actors | Entity snapshots | Entities helpers |
| Travel | Path requests and unlocked destinations | Configurable travel |
| Quest lists | Quest reads and requests | Quest journal |
Character
game.local_position()
Parameters: None. Returns: {x, y, z} in game world units, or nil, error when the character or its position is unavailable.
All three coordinates are finite numbers. Use the same coordinate units with game.request_path(), game.path_destination(), and game.destination_marker().
game.local_flight_ground()
Parameters: None. Returns: {distance_cm, water, player_address, map, movement_tick}, or nil, error.
Reads the same distance and ground/water choice used by the flight altitude display. distance_cm measures from the character's feet to the surface below in centimetres; water is true for water and false for ground. The read is available only while flying and rejects missing surfaces or a change of character, map, or movement tick. It requires a runtime that provides this new API.
Ground below does not by itself mean a ledge is wide or flat enough to land. Confirm a supporting floor and the walking state before continuing ground movement.
game.local_health_fraction()
Parameters: None. Returns: Displayed health fraction from 0 to 1, or nil, error.
0 is a valid reading. This is the character's displayed health bar, not an absolute health total. Use game.local_displayed_resources() for numeric displayed health and mana pairs.
game.local_level()
Parameters: None. Returns: The character's integer level, or nil, error.
The level remains available when its label is hidden. It can be temporarily unavailable while the character or world is loading; check for nil before using it.
game.local_name()
Parameters: None. Returns: Character name as UTF-8 text, or nil, error.
The returned name is nonempty, up to 128 bytes, and contains no ASCII control characters.
game.local_character_class()
Parameters: None. Returns: Character class code, or nil, error.
| Code | Class | Code | Class | Code | Class |
|---|---|---|---|---|---|
| 1 | Novice | 4 | Ranger | 7 | Sorcerer |
| 2 | Gladiator | 5 | Assassin | 8 | Cleric |
| 3 | Templar | 6 | Elementalist | 9 | Chanter |
game.local_pc_data_id()
Parameters: None. Returns: Positive character data identifier, or nil, error. It is distinct from the class code and should not be used as its replacement.
game.local_resource_text()
Parameters: None. Returns: {health, mana} strings as displayed by the game, or nil, error.
Both values are nonempty display strings. Their formatting can vary. Use game.local_displayed_resources() when you need validated numeric pairs instead of text.
game.local_sp_text()
Parameters: None. Returns: Nonempty displayed SP text, or nil, error while it is unavailable.
The text is returned without numeric conversion. It is not a numeric skill-point or stamina reading.
game.local_displayed_resources()
Parameters: None. Returns: {health={current, maximum}, mana={current, maximum}} with integer values when both displays use current / maximum, or nil, error.
Both strings must have that format. Numbers may use thousands separators, as in 9,400/9,400. A different display format makes the whole call unavailable rather than returning a partial result. These are displayed values and may update independently of an action request.
local resources, err = game.local_displayed_resources()
if not resources then
log.warn(err)
else
log.info(string.format("Health %d / %d, mana %d / %d",
resources.health.current, resources.health.maximum,
resources.mana.current, resources.mana.maximum))
endlocal level, err = game.local_level()
if level == nil then
log.warn(err)
else
local position = game.local_position()
if position then
log.info(string.format("Level %d at %.0f, %.0f", level, position.x, position.y))
end
endParty
game.party_members()
Parameters: None. Returns: An array of party member rows in the order the party list shows them, or nil, error while the party list is unavailable. Solo play returns an empty array.
| Field | Meaning |
|---|---|
index | One-based position in the party list. Pass it to game.select_party_member(). |
widget | Opaque handle of the member's party-list row. |
name | Member name as displayed. |
hp | Displayed health fraction from 0 to 1. |
mp | Displayed mana fraction from 0 to 1, when the row shows a mana bar. |
level | Displayed level, when it is a number. |
hp_current, hp_maximum | Displayed health numbers, only when the row shows them as current/maximum. |
dead, offline, out_of_range | true while the row shows that state. |
leader | true for the party leader. |
targeted | true while the row shows the member as your current target. |
Your own character is not in the list; use game.local_health_fraction(). Pending invites are skipped, and alliance rows are not included. The values are the party list's displayed state and update at its rate. This requires a runtime that provides this new API.
game.select_party_member()
Parameters: One-based index from game.party_members() and an optional expected name: game.select_party_member(index[, name]). Returns: true after the target request, or nil, error.
This does the same as clicking the member in the party list. When you pass name, the call fails with party member changed instead of targeting someone else if the list changed. Check the member's targeted flag on a later tick before casting.
local members = game.party_members()
for _, member in ipairs(members or {}) do
if not member.dead and not member.offline and not member.out_of_range and member.hp < 0.6 then
if game.select_party_member(member.index, member.name) then
log.info(string.format("Healing %s at %.0f%%", member.name, member.hp * 100))
end
break
end
endCurrent world
game.current_level_name()
Parameters: None. Returns: Loaded level name as UTF-8 text, or nil, error. This is different from the numeric game map ID.
Use game.current_map_id() for an ID-based comparison; a level name is not a replacement for that ID.
game.current_map_id()
Parameters: None. Returns: Positive numeric map ID, or nil, error.
game.current_area_id()
Parameters: None. Returns: Positive numeric area ID, or nil, error.
Read both IDs again after travel. An unavailable read during a transition should not be treated as a new map or area with ID zero.
game.entities(radius, limit, filter)
Parameters:
| Name | Default | Accepted values |
|---|---|---|
radius | 3000 | Finite number greater than 0 and at most 100000, in world units |
limit | 128 | Integer from 1 to 512 |
filter | None | character, player, mob, npc, pet, object, loot, gatherable, or actor |
Returns: An array of records with id, name, kind, subkind, x, y, z, distance, and alive, or nil, error. Filtering happens before the result limit.
| Field | Meaning |
|---|---|
id | Temporary entity identifier; refresh the snapshot after world changes |
uid | Game key for this entity, when it has one (Sharp 0.4.10). Use it with game.select_target() |
name | Entity name |
kind, subkind | Entity category and more specific category |
x, y, z | Position in world units |
distance | Distance from the local character in world units |
alive | Current observed alive state for characters |
The local character is excluded. Results are not sorted by distance and can be incomplete when the limit is reached. An empty array is a valid snapshot; it differs from an unavailable read. Use entities.nearest() when you need the nearest matching result.
local mobs, err = game.entities(2500, 50, "mob")
if not mobs then
log.warn(err)
else
for _, mob in ipairs(mobs) do
if mob.alive then log.info(mob.name) end
end
endThe entities library provides nearest and living-character helpers.
game.player_power(entity_id)
Parameters: The id of a remote player returned by game.entities(..., "player").
Returns: { combat_power, gear_score, age_ms, stale }, or nil, error while
no matching appearance packet is available. The three numeric fields are integers;
stale becomes true when the appearance snapshot is older than five minutes.
It remains the last observed value while that actor is present, so it may no longer
match current equipment. Receive capture starts automatically after DLL initialization,
including while Player ESP is hidden. A player visible before the DLL loaded may
need to leave and reappear before a value is available. Values are cleared on world change,
packet loss, or when the player disappears. This call only reads observed
packets; it does not request another player's profile.
local players = game.entities(3000, 128, "player") or {}
for _, player in ipairs(players) do
local power = game.player_power(player.id)
if power then
log.info(string.format("%s: CP %d, gear %d", player.name,
power.combat_power, power.gear_score))
end
endMovement
game.clear_target()
Parameters: None. Returns: true when the clear request is sent, or nil, error. This call clears the current selection; it does not select another target or stop an existing path.
game.request_path(x, y, z)
Parameters: Finite world coordinates. Returns: true when a path request is sent, or nil, error. Check position as movement continues.
The coordinates use the same units as game.local_position(). A sent request does not guarantee a reachable destination or arrival. Use a later position read to decide whether to finish or retry your own workflow; avoid sending the same request every tick.
game.path_destination()
Parameters: None. Returns: Current path destination as {x, y, z}, or nil, error when unavailable.
This is the path endpoint, not necessarily the tracked quest marker. For that marker, use game.destination_marker().
game.destination_marker()
Parameters: None. Returns: Tracked destination as {id, x, y, z}, or nil, error. Coordinates use world units.
The marker is a snapshot. Re-read it when tracking changes rather than keeping a destination indefinitely.
game.popup_message_text()
Parameters: None. Returns: The text of a visible game message popup, or nil, error when no single message is available. This call only reads the text.
It does not dismiss the popup or return a numeric message code. Multiple matching visible messages are reported unavailable rather than choosing one.
local destination = game.path_destination()
if destination then
log.info(string.format("Path to %.0f, %.0f", destination.x, destination.y))
endSee configurable travel for a complete module.
Dungeon auto-move
The game normally refuses quest auto-move inside dungeons. These calls lift that refusal for the current session so tracked quest destinations keep working there. Turning the option off restores the original behavior.
game.set_dungeon_automove(enabled)
Parameters: true to allow quest auto-move in dungeons, false to restore the refusal. Returns: true when applied, or nil, error.
The request only succeeds when the running game supports it; otherwise it returns an error and nothing changes. Panic mode turns the option off. Also available as sdk.set_dungeon_automove.
game.dungeon_automove_status()
Parameters: None. Returns: A table with available, enabled, gates, flag_probe, flag_even, flag_odd, has_flags and message_id, or nil, error.
available tells whether the running game supports the option. enabled tells whether the option is currently on. The remaining fields describe what was found and stay the same while the game runs. Also available as sdk.dungeon_automove_status.
local status = game.dungeon_automove_status()
if status and status.available and not status.enabled then
game.set_dungeon_automove(true)
endTravel
game.is_teleport_unlocked(id)
Parameters: Destination ID from 1 to 2147483647. Returns: true or false, or nil, error for an invalid ID or unavailable destination list.
game.unlocked_dungeon_waypoints()
Parameters: None. Returns: An array of unlocked dungeon waypoint IDs in current list order, an empty array when none are unlocked, or nil, error when unavailable.
The IDs are not coordinates. game.is_teleport_unlocked() answers whether a particular destination is unlocked; neither call requests a teleport.
local unlocked, err = game.is_teleport_unlocked(12345)
if unlocked == nil then
log.warn(err)
elseif unlocked then
log.info("Destination unlocked")
endItems and shortcuts
game.use_item(uid)
Parameters: Integer item UID from 1 to 9223372036854775807. This identifies one inventory item, not its item-type ID.
Returns: true when the client accepts the item-use request, or nil, error. Check the game's inventory afterward to see whether the item was consumed. Do not repeat an item-use request just because consumption is not visible on the same tick.
game.shortcut_press(slot)
Parameters: Integer slot from 0 to 59. Returns: true when the press edge is sent, or nil, error.
Slots are zero-based. Pair a successful press with game.shortcut_release(); the caller owns the delay between those edges.
game.shortcut_release(slot)
Parameters: Integer slot from 0 to 59. Returns: true when the release edge is sent, or nil, error. A sent edge does not confirm skill activation.
game.place_skill(skill_id, slot, combo_index)
Parameters: Integer skill ID from 1 to 4294967295, integer slot from 0 to 255, and integer combo index from 0 to 3.
Returns: true when the client accepts the request, or nil, error. Check the game's shortcut bar afterward. Placement slots have a wider range than press/release slots; placing a skill does not activate it.
function on_start()
local ok, err = script.start_worker(function()
local pressed, pressError = game.shortcut_press(0)
if not pressed then
log.warn(pressError)
return
end
script.sleep(50)
local released, releaseError = game.shortcut_release(0)
if not released then log.warn(releaseError) end
end)
if not ok then log.warn(err) end
endThis example belongs in a module. script.sleep() only works inside its managed worker; it cannot be called directly from on_tick.
Quests
Quest lists contain quest IDs only. They do not provide names, objectives, progress, tracking IDs, or active quest UIDs. A quest ID, tracking ID, and active quest UID are different values; do not substitute one for another.
game.active_quest_ids()
Parameters: None. Returns: Active quest IDs in current list order, an empty array when none are active, or nil, error.
Each entry is a quest ID, not the UID required by game.submit_quest().
game.available_quest_ids()
Parameters: None. Returns: Available quest IDs in current list order, an empty array when none are available, or nil, error.
game.completed_quest_ids()
Parameters: None. Returns: Completed quest IDs in current list order, an empty array when none are completed, or nil, error.
game.claim_quest(id)
Parameters: Integer quest ID from 1 to 4294967295. Use an ID from game.available_quest_ids().
Returns: true when the claim request is sent, or nil, error. Re-read game.active_quest_ids() on a later tick to observe whether the quest became active.
game.execute_quest(id, track_id)
Parameters: Integer quest ID from 1 to 4294967295 and integer track ID from 0 to 4294967295. Supply the tracking ID appropriate to that quest; the ID-only lists do not supply it.
Returns: true when the quest action request is sent, or nil, error. Check the game's quest progress afterward; a sent action does not confirm progress.
game.submit_quest(quest_uid, reward_index)
Parameters: Integer active quest UID from 1 to 2147483647 and integer reward index from -1 to 2147483647. Use -1 when no reward choice is needed. The UID differs from the quest ID and is not returned by the ID-only quest lists.
Returns: true when the client accepts the reward request, or nil, error. Re-read the active and completed lists later to observe completion.
local available, err = game.available_quest_ids()
if not available then
log.warn(err)
elseif #available > 0 then
local requested, requestError = game.claim_quest(available[1])
if not requested then log.warn(requestError) end
endSee the quest journal guide for a module that handles all three lists.