Class Dialog

java.lang.Object
com.botwithus.bot.api.dialog.Dialog

public final class Dialog extends Object
Reads RS3 conversation dialogs: selects options on the multi-choice dialog (interface DIALOG_OPTIONS, 1188 — "select an option") and advances a text-only NPC-chat page (interface DIALOG_NPC, 1184).

The text→component correlation

The dialog is laid out as a fixed set of option rows (LAYER components) hanging directly off the options container (component OPTIONS_CONTAINER). The visible text is not on the row: each row's subtree carries two TEXT leaves — the option label ("What's wrong?") and a number cell ("1."). The number cell yields the 1-based option index directly, so the row→index mapping is read from the game rather than assumed.

Crucially, selection targets the row (component 8/13/18/23/28…) via the DIALOGUE action (type 30, the engine's resume / pausebutton path) — not the text leaf that carries the label, and not a COMPONENT click (which dispatches but the server ignores, leaving the dialogue stuck). This class walks label→row so callers select by text or index and the right component is driven the right way. Verified live against interface 1188: label "What's wrong?" lives on component 6, three levels under row component 8, and a DIALOGUE action on row 8 advances the dialogue.

if (Dialog.isOpen(api)) {
    Dialog.select(api, "What's wrong?");   // clicks row component 8
}
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The multi-choice dialog interface ("select an option").
    static final int
    The text-only NPC-chat dialog interface (no options, just a continue button).
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Advances a text-only NPC-chat page (interface 1184) by driving its continue / next button (component 15) with the DIALOGUE action.
    static boolean
    True when the text-only NPC-chat dialog (1184) is open.
    static boolean
    True when the multi-choice dialog is open with at least one selectable option.
    The selectable options currently shown, in display order.
    static boolean
    select(GameAPI api, int index)
    Selects the option with the given 1-based index (as shown by its "N." cell).
    static boolean
    select(GameAPI api, String text)
    Selects the first option whose label contains text (case-insensitive, markup-stripped, whitespace-normalized).

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MULTI_CHOICE_INTERFACE

      public static final int MULTI_CHOICE_INTERFACE
      The multi-choice dialog interface ("select an option").
      See Also:
    • NPC_CHAT_INTERFACE

      public static final int NPC_CHAT_INTERFACE
      The text-only NPC-chat dialog interface (no options, just a continue button).
      See Also:
  • Method Details

    • isOpen

      public static boolean isOpen(GameAPI api)
      True when the multi-choice dialog is open with at least one selectable option.
    • options

      public static List<DialogOption> options(GameAPI api)
      The selectable options currently shown, in display order. Empty when the multi-choice dialog isn't open. One get_interface_tree round-trip; the row/label/number walk is then in-memory.
    • select

      public static boolean select(GameAPI api, String text)
      Selects the first option whose label contains text (case-insensitive, markup-stripped, whitespace-normalized). Clicks the option row.
      Returns:
      true when a matching option was found and clicked
    • select

      public static boolean select(GameAPI api, int index)
      Selects the option with the given 1-based index (as shown by its "N." cell). Clicks the option row.
      Returns:
      true when an option with that index was found and clicked
    • isChatOpen

      public static boolean isChatOpen(GameAPI api)
      True when the text-only NPC-chat dialog (1184) is open. 1184 fully unloads when the page closes, so its root component resolving is an exact gate. (Note: walking its tree from the root misses the content — the NPC line is a flat sibling under a different parent, not a descendant of component 0.)
    • continueChat

      public static boolean continueChat(GameAPI api)
      Advances a text-only NPC-chat page (interface 1184) by driving its continue / next button (component 15) with the DIALOGUE action.

      A manual click on that button emits exactly this action — verified via the agent's DoAction hook: action=30 p1=0 p2=-1 p3=(1184<<16)|15. Spacebar is the keyboard equivalent, routed through the button's type-10 key trigger. A COMPONENT click would dispatch but not advance.

      Returns:
      true when the NPC-chat dialog was open and a continue was queued; false when it isn't open