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:

ParameterTypeRequiredDescription
textstringYesText 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:

ParameterTypeRequiredDescription
numbernumberYesNumber to send

Returns:

  • boolean - True if successful

Example:

chat:send_number(100)  -- Send 100 items

get_options

chat:get_options() -> table

Get available chat options.

Returns:

  • table - Array of option strings

select_option

chat:select_option(text: string) -> boolean

Select option by text.

Parameters:

ParameterTypeRequiredDescription
textstringYesOption 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
    
    local options = chat:get_options()
    for _, option in ipairs(options) do
        if option:find(option_text) then
            return chat:select_option(option)
        end
    end
    
    logger:warn("Option not found: " .. option_text)
    return false
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

Related APIs

  • Menu API - Right-click menus
  • NPCs API - NPC interaction