Quest Functions
Overview
The core.quests module provides functions for interacting with quest dialogs, the quest log, gossip frames, trainer services, and item information. These functions cover the full lifecycle of quest management from accepting quests at NPCs to tracking and completing them.
Quest Dialog Functions
core.quests.accept_quest
Syntax
core.quests.accept_quest() -> nil
Accepts the current quest dialog. Call this when the quest detail frame is shown after selecting a quest from an NPC.
core.quests.close_quest
Syntax
core.quests.close_quest() -> nil
Closes the quest dialog frame.
core.quests.decline_quest
Syntax
core.quests.decline_quest() -> nil
Declines the current quest dialog, dismissing the quest offer.
core.quests.complete_quest
Syntax
core.quests.complete_quest() -> nil
Completes the current quest dialog. Use this when turning in a quest that has no reward choices, or after selecting a reward with get_quest_reward.
core.quests.get_quest_reward
Syntax
core.quests.get_quest_reward(choice: integer) -> nil
Parameters
choice:integer- The index of the reward choice to select.
Selects a reward choice and completes the quest. Use this for quests that offer multiple reward options.
Example Usage
-- Select the first reward option and complete the quest
core.quests.get_quest_reward(1)
core.quests.confirm_accept_quest
Syntax
core.quests.confirm_accept_quest() -> nil
Confirms quest acceptance for escort-type quests that require an additional confirmation step before starting.
core.quests.select_active_quest
Syntax
core.quests.select_active_quest(index: integer) -> nil
Parameters
index:integer- The index of the active quest in the NPC's quest list.
Selects an active (in-progress or completable) quest at the NPC dialog. This opens the quest detail or completion frame for that quest.
core.quests.select_available_quest
Syntax
core.quests.select_available_quest(index: integer) -> nil
Parameters
index:integer- The index of the available quest in the NPC's quest list.
Selects an available (not yet accepted) quest at the NPC dialog. This opens the quest detail frame for that quest.
core.quests.get_active_title
Syntax
core.quests.get_active_title(index: integer) -> string
Parameters
index:integer- The index of the active quest.
string: The title of the active quest at the NPC.
Returns the title of an active quest listed at the current NPC dialog.
core.quests.get_available_title
Syntax
core.quests.get_available_title(index: integer) -> string
Parameters
index:integer- The index of the available quest.
string: The title of the available quest at the NPC.
Returns the title of an available quest listed at the current NPC dialog.
core.quests.get_active_level
Syntax
core.quests.get_active_level(index: integer) -> integer
Parameters
index:integer- The index of the active quest.
integer: The level of the active quest at the NPC.
Returns the level of an active quest listed at the current NPC dialog.
core.quests.get_available_level
Syntax
core.quests.get_available_level(index: integer) -> integer
Parameters
index:integer- The index of the available quest.
integer: The level of the available quest at the NPC.
Returns the level of an available quest listed at the current NPC dialog.
core.quests.get_reward_money
Syntax
core.quests.get_reward_money() -> integer
integer: The copper reward amount for the current quest.
Returns the monetary reward in copper for the currently displayed quest dialog.
Example Usage
local copper = core.quests.get_reward_money()
local gold = math.floor(copper / 10000)
local silver = math.floor((copper % 10000) / 100)
core.log(string.format("Quest reward: %dg %ds", gold, silver))
core.quests.get_quest_item_link
Syntax
core.quests.get_quest_item_link(type: string, index: integer) -> string
Parameters
type:string- The type of quest item ("reward"or"choice").index:integer- The index of the item.
string: The item link for the quest reward or choice item.
Returns the item link string for a quest reward or choice item in the current quest dialog.
Quest Log Functions
core.quests.get_num_quest_log_entries
Syntax
core.quests.get_num_quest_log_entries() -> integer
integer: The number of quest log entries (including headers).
Returns the total number of entries in the quest log. This includes both zone headers and quest entries.
core.quests.get_quest_log_title
Syntax
core.quests.get_quest_log_title(index: integer) -> table
Parameters
index:integer- The quest log entry index.
table: A table containing quest log entry details.
Return Table Fields:
| Field | Type | Description |
|---|---|---|
title | string | The title of the quest or header |
level | integer | The quest level |
quest_id | integer | The unique quest ID |
is_header | boolean | Whether this entry is a zone header |
is_complete | boolean | Whether the quest is complete |
Returns detailed information about a quest log entry. Use is_header to distinguish zone headers from actual quests. Refer to the .api definition for the complete list of fields.
Example Usage
local num_entries = core.quests.get_num_quest_log_entries()
for i = 1, num_entries do
local info = core.quests.get_quest_log_title(i)
if not info.is_header then
local status = info.is_complete and "COMPLETE" or "In Progress"
core.log(string.format("[%d] %s (Lv %d) - %s", info.quest_id, info.title, info.level, status))
end
end
core.quests.is_quest_flagged_completed
Syntax
core.quests.is_quest_flagged_completed(quest_id: integer) -> boolean
Parameters
quest_id:integer- The quest ID to check.
boolean:trueif the quest was ever completed by this character.
Checks whether a quest has been completed at any point in the past. This queries the server's completion history, not the current quest log.
core.quests.is_on_quest
Syntax
core.quests.is_on_quest(quest_id: integer) -> boolean
Parameters
quest_id:integer- The quest ID to check.
boolean:trueif the quest is currently in the quest log.
Checks whether a specific quest is currently active in the player's quest log.
Example Usage
local QUEST_ID = 12345
if core.quests.is_on_quest(QUEST_ID) then
core.log("Quest is in progress")
elseif core.quests.is_quest_flagged_completed(QUEST_ID) then
core.log("Quest already completed")
else
core.log("Quest not started")
end
core.quests.select_quest_log_entry
Syntax
core.quests.select_quest_log_entry(index: integer) -> nil
Parameters
index:integer- The quest log entry index to select.
Selects a quest log entry. This is required before calling functions that operate on the "selected" quest, such as quest_log_push_quest or set_abandon_quest.
core.quests.get_num_quest_leader_boards
Syntax
core.quests.get_num_quest_leader_boards(quest_log_index: integer) -> integer
Parameters
quest_log_index:integer- The quest log entry index.
integer: The number of objectives for the quest.
Returns the number of objectives (leaderboard entries) for a quest in the quest log.
core.quests.get_quest_log_leader_board
Syntax
core.quests.get_quest_log_leader_board(obj_index: integer, quest_log_index: integer) -> string
Parameters
obj_index:integer- The objective index.quest_log_index:integer- The quest log entry index.
string: The objective description text (e.g.,"Wolves slain: 3/10").
Returns the text for a specific quest objective. The text typically includes the current progress and goal.
Example Usage
local num_objectives = core.quests.get_num_quest_leader_boards(5)
for j = 1, num_objectives do
local text = core.quests.get_quest_log_leader_board(j, 5)
core.log(" Objective: " .. text)
end
core.quests.get_quest_log_item_link
Syntax
core.quests.get_quest_log_item_link(type: string, index: integer, quest_id: integer) -> string
Parameters
type:string- The type of item ("reward"or"choice").index:integer- The item index.quest_id:integer- The quest ID.
string: The item link for the quest log reward or choice item.
Returns the item link string for a reward or choice item associated with a quest in the quest log.
core.quests.add_quest_watch
Syntax
core.quests.add_quest_watch(index: integer, watch_time: number) -> nil
Parameters
index:integer- The quest log entry index.watch_time:number- Duration in seconds to watch the quest.
Adds a quest to the on-screen quest tracker for the specified duration.
core.quests.remove_quest_watch
Syntax
core.quests.remove_quest_watch(index: integer) -> nil
Parameters
index:integer- The quest log entry index.
Removes a quest from the on-screen quest tracker.
core.quests.quest_log_push_quest
Syntax
core.quests.quest_log_push_quest() -> nil
Shares the currently selected quest log entry with the party. You must first select the quest using select_quest_log_entry.
core.quests.set_abandon_quest
Syntax
core.quests.set_abandon_quest() -> nil
Marks the currently selected quest log entry for abandonment. You must first select the quest using select_quest_log_entry, then call abandon_quest to confirm.
core.quests.abandon_quest
Syntax
core.quests.abandon_quest() -> nil
Confirms abandonment of the quest previously marked with set_abandon_quest.
Example Usage
-- Abandon quest at log index 3
core.quests.select_quest_log_entry(3)
core.quests.set_abandon_quest()
core.quests.abandon_quest()
Gossip Functions
core.quests.get_gossip_options
Syntax
core.quests.get_gossip_options() -> table
table: An array of gossip options available from the NPC.
Returns the list of gossip options available from the currently open gossip frame. Each entry contains information about a dialog option the NPC offers.
core.quests.select_gossip_option
Syntax
core.quests.select_gossip_option(id: integer) -> nil
Parameters
id:integer- The gossip option ID to select.
Selects a gossip option from the NPC dialog.
core.quests.get_gossip_available_quests
Syntax
core.quests.get_gossip_available_quests() -> table
table: An array of available quests from the gossip NPC.
Returns the list of quests available to pick up from the gossip NPC.
core.quests.get_gossip_active_quests
Syntax
core.quests.get_gossip_active_quests() -> table
table: An array of active quests at the gossip NPC.
Returns the list of active (in-progress or completable) quests at the gossip NPC.
core.quests.select_gossip_available_quest
Syntax
core.quests.select_gossip_available_quest(quest_id: integer) -> nil
Parameters
quest_id:integer- The quest ID to select.
Selects an available quest from the gossip frame by quest ID.
core.quests.select_gossip_active_quest
Syntax
core.quests.select_gossip_active_quest(quest_id: integer) -> nil
Parameters
quest_id:integer- The quest ID to select.
Selects an active quest from the gossip frame by quest ID.
core.quests.close_gossip
Syntax
core.quests.close_gossip() -> nil
Closes the gossip frame.
core.quests.is_gossip_frame_shown
Syntax
core.quests.is_gossip_frame_shown() -> boolean
boolean:trueif the gossip frame is currently open; otherwise,false.
Checks whether the gossip frame is currently displayed.
Example Usage
if core.quests.is_gossip_frame_shown() then
local options = core.quests.get_gossip_options()
core.log("Gossip options available: " .. #options)
end
Trainer Functions
core.quests.get_num_trainer_services
Syntax
core.quests.get_num_trainer_services() -> integer
integer: The number of services available from the trainer.
Returns the number of training services available from the currently open trainer window.
core.quests.get_trainer_service_info
Syntax
core.quests.get_trainer_service_info(index: integer) -> table
Parameters
index:integer- The index of the trainer service.
table: A table containing the trainer service details.
Returns detailed information about a specific trainer service at the given index.
core.quests.get_trainer_service_cost
Syntax
core.quests.get_trainer_service_cost(index: integer) -> integer
Parameters
index:integer- The index of the trainer service.
integer: The cost in copper.
Returns the cost in copper of a trainer service at the given index.
core.quests.buy_trainer_service
Syntax
core.quests.buy_trainer_service(index: integer) -> nil
Parameters
index:integer- The index of the trainer service to purchase.
Purchases a trainer service at the given index.
Example Usage
local num_services = core.quests.get_num_trainer_services()
for i = 1, num_services do
local info = core.quests.get_trainer_service_info(i)
local cost = core.quests.get_trainer_service_cost(i)
local gold = math.floor(cost / 10000)
core.log(string.format("Service %d: %dg", i, gold))
end
-- Buy the first service
core.quests.buy_trainer_service(1)
Item Info Functions
core.quests.get_item_spell
Syntax
core.quests.get_item_spell(item_id_or_link) -> string
Parameters
item_id_or_link:integer|string- An item ID or item link string.
string: The spell name associated with the item.
Returns the spell name that an item casts or teaches. Useful for identifying quest items that trigger specific actions.
core.quests.get_item_info
Syntax
core.quests.get_item_info(item_id_or_link) -> table
Parameters
item_id_or_link:integer|string- An item ID or item link string.
table: A table containing item information.
Returns an information table for the specified item. The table includes details such as name, quality, item level, and other properties.
Complete Examples
Example: Auto-Accept and Turn In Quests at NPC
local function handle_npc_quests()
-- Check if gossip frame is open
if not core.quests.is_gossip_frame_shown() then
return
end
-- First, turn in any completable active quests
local active = core.quests.get_gossip_active_quests()
for _, quest in ipairs(active) do
core.quests.select_gossip_active_quest(quest.quest_id)
core.quests.complete_quest()
return -- Process one at a time
end
-- Then, accept any available quests
local available = core.quests.get_gossip_available_quests()
for _, quest in ipairs(available) do
core.quests.select_gossip_available_quest(quest.quest_id)
core.quests.accept_quest()
return -- Process one at a time
end
end
Example: Quest Progress Tracker
local function print_quest_progress()
local num_entries = core.quests.get_num_quest_log_entries()
for i = 1, num_entries do
local info = core.quests.get_quest_log_title(i)
if not info.is_header then
core.log(string.format("[%d] %s", info.quest_id, info.title))
local num_objectives = core.quests.get_num_quest_leader_boards(i)
for j = 1, num_objectives do
local text = core.quests.get_quest_log_leader_board(j, i)
core.log(" " .. text)
end
end
end
end