# Chat The {ref}`Chat` interface is the interface that shows up at the bottom left corner of the game client where you can communicate with other players, receive game messages and even interact with some options and menus it hosts like the {ref}`Make` menu. ```{figure} ../../images/chat_interface.png ``` - - - (EChatColor)= ## EChatColor enum ```pascal EChatColor = enum(BLACK, MAROON .. NAVY, GREEN); ``` Enum representing each of the available chat text colors. - - - (EIron)= ## EIron enum ```pascal EIron = enum( NONE, IRONMAN, HARDCORE, ULTIMATE, GROUP, HARCORE_GROUP, UNRANKED_GROUP ); ``` Enum representing each of the available ironman types. - - - ## TChat Main record used to interact with the {ref}`Chat` interface. - - - ### Chat.SetupInterface ```pascal procedure TChat.SetupInterface(); ``` Internal method used to setup the {ref}`TChat` coordinates. This is automatically called for you on the {ref}`Chat variable`. - - - ### Chat.Tabs variable ```pascal Tabs: TChatTabs; ``` For more information on chat tabs read {ref}`ChatTabs`. You can access the {ref}`TChat` {ref}`ChatTabs` through the `Tabs variable`: ```pascal ShowOnTarget(Chat.Tabs.Bounds); ``` ```{figure} ../../images/chattabs_bounds.png ``` - - - #### Chat.GetColors ```pascal function TChat.GetColors(colors: EChatColorArray): TColorArray; ``` Convenience method used to conver the human readable `colors` in a `EChatColorArray` format into a `TColorArray` which has the colors in BGR format. Example: ```pascal WriteLn Chat.GetColors([EChatColor.RED, EChatColor.WHITE]); ``` - - - ### Chat.GetDisplayNameBox ```pascal function TChat.GetDisplayNameBox(out color: Integer): TBox; function TChat.GetDisplayNameBox(): TBox; overload; ``` Returns the bounds of the display name on the {ref}`Chat` box. You can optionally get the display name color back through the `color` variable. Example: ```pascal ShowOnTarget(Chat.GetDisplayNameBox()); ``` - - - ### Chat.GetDisplayName ```pascal function TChat.GetDisplayName(): String; ``` Returns the account display name on the {ref}`Chat` box as a string. Example: ```pascal WriteLn Chat.GetDisplayName(); ``` - - - ### Chat.GetIronManType ```pascal function TChat.GetIronManType() : EIron; ``` Returns the account ironman type. Example: ```pascal WriteLn Chat.GetIronManType(); ``` - - - ### Chat.IsTransparent ```pascal function TChat.IsTransparent(): Boolean; ``` Returns true if the {ref}`Chat` box is in transparent mode. Example: ```pascal WriteLn Chat.IsTransparent(); ``` - - - ### Chat.IsOpen ```pascal function TChat.IsOpen(): Boolean; ``` Returns True/False if the {ref}`Chat` is open. Example: ```pascal if Chat.IsOpen() then ShowOnTarget(Chat.Bounds); ``` - - - ### Chat.Close ```pascal function TChat.Close(): Boolean; ``` Attempts to close the {ref}`Chat`interface. Example: ```pascal WriteLn Chat.Close(); ``` - - - ### Chat Queries A chat query is when you have some kind of question on the chatbox which you have to reply to. For example, when you try to "withdraw-x" from the bank, you are asked for the quantity: ```{figure} ../../images/chat_query.png A chat query. ``` - - - #### Chat.GetQuery ```pascal function TChat.GetQuery(): String; ``` Returns the query shown on the {ref}`Chat` interface if any as a string. Example: ```pascal WriteLn Chat.Close(); ``` - - - #### Chat.GetQueryAnswer ```pascal function TChat.GetQueryAnswer(): String; ``` Returns the query current answer to the query in the {ref}`Chat` interface if any. Example: ```pascal WriteLn Chat.GetQueryAnswer(); ``` - - - #### Chat.FindQuery ```pascal function TChat.FindQuery(const query: String; matchCase: Boolean = False): Boolean; ``` Returns the True/False if the {ref}`Chat` interface currently has the specified `query` visible. Example: ```pascal WriteLn Chat.FindQuery('Enter amount'); ``` - - - #### Chat.WaitQuery ```pascal function TChat.WaitQuery( const query: String; matchCase: Boolean; time: Integer = TICK; interval: Integer = -1 ): Boolean; ``` Returns the true if the specified `query` is visible in the {ref}`Chat` interface within `time` milliseconds. Example: ```pascal WriteLn Chat.WaitQuery('Enter amount'); ``` - - - #### Chat.AnswerQuery ```pascal function TChat.AnswerQuery( query, answer: String; waitTime: Integer = TICK; interval: Integer = -1 ): Boolean; ``` Attempts to reply to the specified `query` with `answer` if it's available in the {ref}`Chat` interface within `waitTime` milliseconds. Example: ```pascal WriteLn Chat.AnswerQuery('Enter amount', '15'); ``` - - - ### Chat.GetMessage ```pascal function TChat.GetMessage(line: Integer): String; ``` Get the message in the specified `line`. For consistency reasons all the symbols are stripped from the result. Example: ```pascal WriteLn Chat.GetMessage(5); ``` Credits: Original design inspired on Olly's solution for this on his 2.0 library. - - - ### Chat.IndexOfMessage ```pascal function TChat.IndexOfMessage(const msg: String; matchCase: Boolean = False): Integer; ``` Find which line has a specific `msg` either entirely or partially if any. Example: ```pascal WriteLn Chat.IndexOfMessage('Hello world'); ``` - - - ### Chat.ContainsMessage ```pascal function TChat.ContainsMessage(const msg: String; matchCase: Boolean = False): Boolean; ``` Returns True/False if the specified `msg` is visible on the {ref}`Chat` interface. Example: ```pascal WriteLn Chat.ContainsMessage('Hello world'); ``` - - - ### Chat.CountNewMessage ```pascal function TChat.CountNewMessage(const msg: String; matchCase: Boolean = False): Integer; ``` Counts how many time the specified `msg` repeats without any other message in between from the most recent one. This can be useful to know if you performed a task sometimes, for example, knowing if you tried to light a fire on top of another: ```pascal {$I WaspLib/main.simba} var oldCount, newCount: Integer; begin oldCount := Chat.CountNewMessage('You can''t light a fire here.'); Inventory.Combine('Tinderbox', 'Logs'); Sleep(8*TICK); newCount := Chat.CountNewMessage('You can''t light a fire here.'); if newCount > oldCount then WriteLn('Tried to light a fire and failed.'); end. ``` - - - ### Chat.GetMessagesString ```pascal function TChat.GetMessagesString(): String; ``` Returns every chat message visible as a string. Example: ```pascal WriteLn Chat.GetMessagesString(); ``` - - - ### Chat.InputHasText ```pascal function TChat.InputHasText(): Boolean; ``` Returns True/False if input line has text written that was never sent. Example: ```pascal WriteLn Chat.InputHasText(); ``` - - - ## Chat variable Global {ref}`TChat` variable.