SRL Archive - SRL Suggestions

Chatbox (non-player chat) Text searching


Cstrike

2010-11-29 10:53:33

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:
{*******************************************************************************
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 :)

traveler

2010-11-29 11:30:58

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

i use that

Shuttleu

2010-11-29 11:32:39

do you need to know what he says, or do you need to know when he says something?

~shut

Cstrike

2010-11-29 11:33:40

I'm going to try FindText :)

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

mormonman

2010-11-29 12:04:49

From: cstrike
I'm going to try FindText :)

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


Use CountColorTolerance();

Shuttleu

2010-11-29 16:55:17

well this is what i use
FindTextTPAEx(clBlack, 0, MCX1, MCY1, MCX2, MCY2, Tempx, Tempy, 'ood day', CharsNPC, Nothing)
you could of course use this

repeat
Wait(100);
if FindTextTPAEx(clBlack, 0, MCX1, MCY1, MCX2, MCY2, Tempx, Tempy, 'ood day', CharsNPC, Nothing) then Break;
until(false);

~shut