# Chat Options The {ref}`Chat` interface options menu that shows up when you are interacting with certain objects or NPCs. ```{figure} ../../images/chat_options.png A chat options menu. ``` - - - ## TChatOption Helper record to handler chat options. - - - (Chat.Options)= ## Chat.Options property ```pascal property TChat.Options(const colors: TColorArray): TChatOptionArray; property TChat.Options: TChatOptionArray; ``` Returns every chat option visible with the specified `colors`. Example: ```pascal img := Target.GetImage(); for option in Chat.Options do img.DrawBox(option.Bounds); img.Show(); img.Free(); ``` ```{figure} ../../images/chat_getoptions.png ``` - - - ### Chat.Options.ToString ```pascal function TChatOptionArray.ToString(): String; ``` Returns the {ref}`TChatOptionArray` as a string with it's options separated with `LINE_SEP`. Example: ```pascal WriteLn Chat.Options.ToString(); ``` - - - ### Chat.Options.IndexOf ```pascal function TChatOptionArray.IndexOf(const txt: String; matchCase: Boolean = True): Integer; ``` Returns the index of the specified `option`. `option` doesn't have to be the entire string of the option, a partial string is fine. Example: ```pascal {$I WaspLib/main.simba} var options: TChatOptionArray; i: Integer; begin options := Chat.Options; i := options.IndexOf('access my bank'); if i >= 0 then ShowOnTarget(options[i].Bounds); end. ``` ```{figure} ../../images/chat_findoption.png ``` - - - ### Chat.Options.Get ```pascal function TChatOptionArray.Get( const txt: String; matchCase: Boolean = True ): TChatOption; ``` Returns the specified `txt` as a `TChatOption` if it exists on the current {ref}`TChatOptionArray`. `txt` doesn't have to be the entire string of the option, a partial string is fine. Example: ```pascal {$I WaspLib/main.simba} begin ShowOnTarget(Chat.Options.Get('access my bank').Bounds); end. ``` ```{figure} ../../images/chat_findoption.png ``` - - - ### Chat.Options.Contains ```pascal function TChatOptionArray.Contains( const txt: String; matchCase: Boolean = True ): Boolean; overload; ``` Returns True/False if the chat option with the specified `txt` text is in this {ref}`TChatOptionArray`. `txt` doesn't have to be the entire string of the option, a partial string is fine. Example: ```pascal WriteLn Chat.Options.Contains('access my bank'); ``` - - - ### Chat.Options.Select ```pascal function TChatOptionArray.Select( const txt: String; matchCase: Boolean = True; keyProbability: Single = -1 ): Boolean; ``` Selects a chat option whose text matches `txt`. Example: ```pascal WriteLn Chat.Options.Select('access my bank'); ``` - - - ## Chat.WaitOption ```pascal function TChat.WaitOption( const txt: String; matchCase: Boolean = True; colors: TColorArray = CHAT_OPTION_COLORS; time: Integer = TICK; interval: Integer = -1 ): Boolean; ``` Same as {ref}`Chat.ContainsOption` but waits up to `time` milliseconds for it to be true. Example: ```pascal WriteLn Chat.WaitOption('access my bank'); ``` - - - ## Chat Options: Continue Methods to handle the continue option in the {ref}`Chat` box. - - - ### Chat.ContainsContinue ```pascal function TChat.ContainsContinue(): Boolean; ``` Returns true if there's a "Click here to continue" option available. Example: ```pascal WriteLn Chat.ContainsContinue(); ``` - - - ### Chat.ContinueChat ```pascal function TChat.ContinueChat(keyProbability: Single = -1): Boolean; ``` Selects the "Click here to continue" chat option. Example: ```pascal WriteLn Chat.ContinueChat(); ``` - - - ### Chat.ContinueUntilOption ```pascal function TChat.ContinueUntilOption(const txt: String; timeout: Int64 = 10*SECOND): Boolean; ``` Selects the "Click here to continue" continuously until `option` is available as a chat option or until we reach the `timeout` which is measured in milliseconds. Example: ```pascal WriteLn Chat.ContinueUntilOption('access my bank'); ``` - - - ## Chat Options: Title Methods and properties to handle the title option in the {ref}`Chat` box. The "Title" option is a text you cannot select and is red, often with 2 swords pointing to it but not always. - - - ### Chat.Title ```pascal property TChat.Title: String; ``` Returns the chat options title. Example: ```pascal WriteLn Chat.Title; ``` - - - ### Chat.IsTitle ```pascal function TChat.IsTitle(const txt: String; similarity: Single = 0.8): Boolean; ``` Returns True/False if the current chat title matches `txt`. Example: ```pascal WriteLn Chat.IsTitle('Select an option'); ``` - - - ### Chat.WaitTitle ```pascal function TChat.WaitTitle( const txt: String; time: Integer = TICK; similarity: Single = 0.8; interval: Integer = -1 ): Boolean; ``` Returns True/False if the current chat title matches `txt` until `time` runs out. Example: ```pascal WriteLn Chat.WaitTitle('Select an option'); ``` - - - ## Chat Options: Level Up Methods to handle level up messages. - - - ### Chat.LeveledUp ```pascal function TChat.LeveledUp(): Boolean; ``` Returns true if we have the level up message on the chat box. Example: ```pascal if Chat.LeveledUp() then Chat.Continue(); ``` - - - ### Chat.HandleLevelUp ```pascal function TChat.HandleLevelUp(keyProbability: Single = -1): Boolean; ``` Attempts to handle the {ref}`Chat.LevelUp` notification. Example: ```pascal Chat.HandleLevelUp(); ```