Results 1 to 6 of 6

Thread: Chatbox (non-player chat) Text searching

  1. #1
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default Chatbox (non-player chat) Text searching

    Is there any way to find the text, for example where the banker says in black NPC text: "Good day. How can I help you?"

    I tried modifying the code:
    Simba Code:
    {*******************************************************************************
    function ClickTextNPC (TextFragment: String; Click, Wait: Boolean): Boolean;
    By: _ChArMz & Narcle (Original by EvilChicken!)
    Description: Returns true if it clicks the option from TextFragment.
    *******************************************************************************}

    function ClickTextNPC (TextFragment: String; Click, Wait: Boolean): Boolean;
    var
      bTxt, wTxt, SearchTPA, TextTPA, Matches : TPointArray;
      Search2D : T2DPointArray;
      b : TBox;
      Height, i, x, y : Integer;
    begin
      Result := false;
      FindColors(bTxt, 0, MCX1, MCY1, MCX2, MCY2);
      FindColors(wTxt, 0, MCX1, MCY1, MCX2, MCY2);

      SearchTPA := CombineTPA(bTxt, wTxt);
      if Length(SearchTPA) < 1 then
        Exit;

      Search2D := SplitTPAEx(SearchTPA, 20, 2);

      TextTPA := LoadTextTPA(TextFragment, NPCChars, Height);
      for i := 0 to High(Search2D) do
      begin
        Result := FindTextTPAinTPA(Height, TextTPA, Search2D[i], Matches);
        if Result and Click then
        begin
          b := GetTPABounds(Search2D[i]);
          GetMousePos(x, y);
          if PointInBox(Point(x, y), b) then
            Mouse(x, y, 2, 1, True)
          else
            with b do
              Mouse(RandomRange(x1, x2), RandomRange(y1 + 2, y2 - 2), 2, 1, True);
          if Wait then
            ChatWait;
        end;
        if Result then
          Break;
      end;
    end;
    This usually finds the text, sometimes is a bit off to the right (but seems to always hit the text though.

    I need it to select chat options.


    Is this code already added in chat.simba somewhere? I might have missed it. Couldn't find anything like it, but would be extremely useful for myself and others who have to select chat options.
    Also very good for random events :P


    If there is working code for the black text, just tell me the function and close this thread

  2. #2
    Join Date
    Jun 2008
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Simba Code:
    FindText(x, y, 'ood day', NPCCHARS, MCX1, MCY1, MCX2, MCY2)

    i use that

  3. #3
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  4. #4
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I'm going to try FindText

    Ideally I need to find when the text comes up, and then click the option

  5. #5
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Quote Originally Posted by cstrike View Post
    I'm going to try FindText

    Ideally I need to find when the text comes up, and then click the option
    Use CountColorTolerance();

  6. #6
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    well this is what i use
    Simba Code:
    FindTextTPAEx(clBlack, 0, MCX1, MCY1, MCX2, MCY2, Tempx, Tempy, 'ood day', CharsNPC, Nothing)
    you could of course use this
    Simba Code:
    repeat
      Wait(100);
      if FindTextTPAEx(clBlack, 0, MCX1, MCY1, MCX2, MCY2, Tempx, Tempy, 'ood day', CharsNPC, Nothing) then Break;
    until(false);

    ~shut

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •