SRL Archive - RS3 Help

Detecting on Screen Text


Lama

2014-10-13 17:06:58

I've been trying to figure out how to get a script to know when something has been said by an NPC that doesn't appear in the chatbox, and I stumbled upon the findText() function in the docs.

I also found this unresolved thread asking pretty much the same thing I am: https://villavu.com/forum/showthread.php?t=110143

So what I am trying to do is to let a script proceed when Pauline Polaris at Livid Farm says one of her phrases that resets the activity.

This is my function so far:

function proceed(): boolean;
var
p: TPoint;
i: integer;

begin
if g <= 0 then
writeLn('Waiting for advancement...');

if (findText(p, ['verything''s advance', 'elp, please!'], [UpChars], mainScreen.getBounds())) then
begin
writeLn('The cycle has begun ...');
result := true;
end;

if (findText(p, ['farm''s moved', 'next stage'], [UpChars], mainScreen.getBounds())) then
begin
writeLn('The cycle has begun ...');
result := true;
end;

if (findText(p, ['ore spellcasting', 'required'], [UpChars], mainScreen.getBounds())) then
begin
writeLn('The cycle has begun ...');
result := true;
end;

if (findText(p, ['ime for more work', 'Time for'], [UpChars], mainScreen.getBounds())) then
begin
writeLn('The cycle has begun ...');
result := true;
end;

g := 1;
end;

The docs say the usage of findText() is:
findText(var p: TPoint; txt, fonts: TStringArray; searchBox: TBox)

Which is what I am doing, and I have tried several difference font types. However, the function just doesn't seem to respond to those actions once they happen in game.

Ideas?

Clarity

2014-10-13 17:18:24

Use UpCharsEx instead of UpChars :)


UpChars won't return any matches for Pauline's chat since, as you can see, they are quite different fonts.
Best of luck with the added Livid Farm functionality. If you're making a complete script I'm sure the community would be interested!

Edit: I see you said you already tried a bunch of font types. If UpCharsEx didn't work, then perhaps you can use OCR.

OCR Documentation


Tesseract is another option, but I believe it is a nightmare when the background is highly variable.

Lama

2014-10-13 17:35:05

From: Clarity

Edit: I see you said you already tried a bunch of font types. If UpCharsEx didn't work, then perhaps you can use OCR.

OCR Documentation



I can safely say I have no idea how to implement this for what I want it to do… hmmm (Ideas anyone?)

Clarity

2014-10-13 18:54:43

From: Lama
I can safely say I have no idea how to implement this for what I want it to do… hmmm (Ideas anyone?)



repeat
writeln(getTextAtEx(mainscreen.getBounds, 0, 0, 3, clYellow, 5, 'UpCharsEx'));
wait(500);
until false;

Ran it, returned the following when she announced the next stage:


T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .
T h e f a r m ' s m o v e d o n t o i t s n e x t s t a g e .


Returns a pretty accurate string. Especially if you narrow the search box, there's a lot you can do with this :)

Lama

2014-10-14 20:54:52

I guess technically I could just tell the script to detect the color of the font, and not really much of what's in it (not a lot of people talk at livid farm, and it wouldn't be a big deal if they did).

Is there a function for detecting a font and it's color, but not necessarily what's in the string? Would I just use a findColorsTolerance(etc) function for mainScreen.getBounds() looking for clYellow? Or whatever value clYellow is.

Kyle

2014-10-14 21:03:14

From: Lama
I guess technically I could just tell the script to detect the color of the font, and not really much of what's in it (not a lot of people talk at livid farm, and it wouldn't be a big deal if they did).

Is there a function for detecting a font and it's color, but not necessarily what's in the string? Would I just use a findColorsTolerance(etc) function for mainScreen.getBounds() looking for clYellow? Or whatever value clYellow is.


Just wondering, did you not see @Clarity;'s post right above you?

Lama

2014-10-14 21:21:33

From: elfyyy
Just wondering, did you not see @Clarity;'s post right above you?


I did, but I tried a few conditional statements regarding the information I got from that, and I couldn't get it to work.

Clarity

2014-10-14 22:13:46

From: Lama
I did, but I tried a few conditional statements regarding the information I got from that, and I couldn't get it to work.



if (getTextAtEx = 'T h e f a r m '' s m o v e d o n t o i t s n e x t s t a g e .') then
doSomething();
That didn't work?

Lama

2014-10-15 18:50:09

From: Clarity

if (getTextAtEx = 'T h e f a r m '' s m o v e d o n t o i t s n e x t s t a g e .') then
doSomething();
That didn't work?


Wait, I don't need the entire

getTextAtEx(mainscreen.getBounds, 0, 0, 3, clYellow, 5, 'UpCharsEx') = 'T h e f a r m '' s m o v e d o n t o i t s n e x t s t a g e .')
Function?

Turpinator

2014-10-15 19:23:25

From: Lama
Wait, I don't need the entire

getTextAtEx(mainscreen.getBounds, 0, 0, 3, clYellow, 5, 'UpCharsEx') = 'T h e f a r m '' s m o v e d o n t o i t s n e x t s t a g e .')
Function?


From: Clarity

if (getTextAtEx = 'T h e f a r m '' s m o v e d o n t o i t s n e x t s t a g e .') then
doSomething();
That didn't work?


was just pseudo code.