Chat API
Interact with dialogue and chat systems.
Functions
is_open
chat:is_open() -> boolean
Check if dialogue is open.
Returns:
boolean- True if dialogue open
chatting
chat:chatting() -> boolean
Alias for is_open().
Returns:
boolean- True if in dialogue
can_continue
chat:can_continue() -> boolean
Check if can click continue button.
Returns:
boolean- True if continue available
click_continue
chat:click_continue() -> boolean
Click the continue button.
Returns:
boolean- True if successful
continue
chat:continue() -> boolean
Alias for click_continue().
Returns:
boolean- True if successful
pending_input
chat:pending_input() -> boolean
Check if awaiting player input.
Returns:
boolean- True if input required
has_input
chat:has_input() -> boolean
Alias for pending_input().
Returns:
boolean- True if input required
send_input
chat:send_input(text: string) -> boolean
Send text input.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to send |
Returns:
boolean- True if successful
Example:
if chat:pending_input() then
chat:send_input("Yes")
end
send_number
chat:send_number(number: number) -> boolean
Send numeric input.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
number | number | Yes | Number to send |
Returns:
boolean- True if successful
Example:
chat:send_number(100) -- Send 100 items
get_options
chat:get_options() -> LuaChatOption[]
Get available chat options.
Returns:
LuaChatOption[]- Array of chat option objects
contains
chat:contains(filter?: ChatOptionFilter) -> boolean
Check if any chat option matches the given filter.
Parameters:
filter(table, optional) - Filter criteria:text(string, optional) - Exact text match (case-insensitive)text_contains(string, optional) - Substring match (case-insensitive)index(integer, optional) - Exact option index (1-5)
Returns:
boolean- True if any option matches
Example:
if chat:contains({ text_contains = "Bank" }) then
chat:select_option("Bank")
end
find_first
chat:find_first(filter?: ChatOptionFilter) -> LuaChatOption | nil
Find the first chat option matching the given filter.
Parameters:
filter(table, optional) - Filter criteria:text(string, optional) - Exact text match (case-insensitive)text_contains(string, optional) - Substring match (case-insensitive)index(integer, optional) - Exact option index (1-5)
Returns:
LuaChatOption | nil- The first matching option, or nil if none found
Example:
local bank_option = chat:find_first({ text_contains = "Bank" })
if bank_option then
bank_option:select() -- uses number key by default
-- or: bank_option:select({ use_mouse = true })
end
find_all
chat:find_all(filter?: ChatOptionFilter) -> LuaChatOption[]
Find all chat options matching the given filter.
Parameters:
filter(table, optional) - Filter criteria (same asfind_first)
Returns:
LuaChatOption[]- All matching options
Example:
local options = chat:find_all({ text_contains = "Yes" })
for _, opt in ipairs(options) do
logger:info("Found option: " .. opt:text())
end
find_last
chat:find_last(filter?: ChatOptionFilter) -> LuaChatOption | nil
Find the last chat option matching the given filter.
Parameters:
filter(table, optional) - Filter criteria (same asfind_first)
Returns:
LuaChatOption | nil- The last matching option, or nil if none found
select_option
chat:select_option(text: string) -> boolean
Select option by text.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Option text to select |
Returns:
boolean- True if successful
Example:
if chat:select_option("Yes") then
logger:info("Selected Yes")
end
get_speaker
chat:get_speaker() -> string
Get who is speaking.
Returns:
string- Speaker name
get_message
chat:get_message() -> string
Get current message text.
Returns:
string- Message content
Common Patterns
Simple Dialogue Flow
local function complete_quest_dialogue()
-- Wait for dialogue
while not chat:is_open() do
sleep(100)
end
-- Continue through dialogue
while chat:can_continue() do
chat:click_continue()
sleep(300)
end
logger:info("Dialogue complete")
end
Handling Options
local function select_dialogue_option(option_text)
if not chat:is_open() then
logger:warn("No dialogue open")
return false
end
return chat:select_option(option_text)
end
-- Or use find_first to get a LuaChatOption object:
local opt = chat:find_first({ text_contains = "Yes" })
if opt then
opt:select() -- keyboard (default)
-- opt:select({ use_mouse = true }) -- mouse click
end
-- Iterate all options:
local options = chat:get_options()
for _, opt in ipairs(options) do
logger:info(opt:index() .. ": " .. opt:text())
end
Text Input Handling
local function handle_text_input(text)
if chat:pending_input() then
logger:info("Sending input: " .. text)
chat:send_input(text)
sleep(300)
return true
end
return false
end
Number Input (Bank X)
local function handle_bank_x(quantity)
if chat:pending_input() then
chat:send_number(quantity)
sleep(300)
return true
end
return false
end
Monitoring Dialogue Content
local function monitor_dialogue()
if chat:is_open() then
local speaker = chat:get_speaker()
local message = chat:get_message()
logger:info("Speaker: " .. speaker)
logger:info("Message: " .. message)
local options = chat:get_options()
if #options > 0 then
logger:info("Options:")
for _, option in ipairs(options) do
logger:info(" - " .. option)
end
end
end
end
Types
LuaChatOption
Represents a selectable chat option.
| Method | Returns | Description |
|---|---|---|
index() | integer | Option index (1-5) |
text() | string | Option text |
select(options?) | boolean | Select this option. Pass { use_mouse = true } to click; omit or false to use number key (1-5). |
ChatOptionFilter
Filter table for find_first, find_all, find_last.
| Field | Type | Description |
|---|---|---|
text | string? | Exact text match (case-insensitive) |
text_contains | string? | Substring match (case-insensitive) |
index | integer? | Exact option index (1-5) |