SRL Archive - Bugs

Function GetTextAt;


bugger0001

2010-03-01 13:43:04

Well, I think I ran into a bug there and I haven't got lazarus on my laptop to check it up…
EDIT: Doup, Simba too can open pascalscript files :p

If I do something like this:
Function SimbaSmeltingScreen: Boolean;
Begin
Result := GetTextAt(158, 367, 0, 0, 0, 128, 0, 4, 'CharsNPC') = 'What';
End;
then in the debug I get this:
[9, 443, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: Welcome to RuneScape
[35, 429, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: ?r?mF? lr?m ?ilv?r ?r?l 6?lJ Nir4ril
[318, 428, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: I Nir4ril
[35, 429, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: ?r?mF? lr?m ?ilv?r ?r?l 6?lJ Nir4ril
[318, 428, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: I Nir4ril
[35, 429, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: ?r?mF? lr?m ?ilv?r ?r?l 6?lJ Nir4ril
[318, 428, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: I Nir4ril
[35, 429, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: ?r?mF? lr?m ?ilv?r ?r?l 6?lJ Nir4ril
[318, 428, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: I Nir4ril
[35, 429, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: ?r?mF? lr?m ?ilv?r ?r?l 6?lJ Nir4ril
[318, 428, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: I Nir4ril
[158, 367, 0, 3, 4, 128, 0, 4, 'CharsNPC']
GetTextAt result: What w
[158, 367, 0, 3, 4, 128, 0, 4, 'CharsNPC']
GetTextAt result: What w
[158, 367, 0, 3, 4, 128, 0, 4, 'CharsNPC']
GetTextAt result: What w
...
[158, 367, 0, 3, 4, 128, 0, 4, 'CharsNPC']
GetTextAt result: What w
[158, 367, 0, 3, 4, 128, 0, 4, 'CharsNPC']
GetTextAt result: What w
[158, 367, 0, 3, 4, 128, 0, 4, 'CharsNPC']
GetTextAt result: What w

As you can see, I called this function quite a few times :p
Anyways, at first it didn't use the params I gave and then after a few tries it used some of them and set some wrong and ended up giving me wrong results.

EDIT: Instead, do this:
Function SimbaSmeltingScreen: Boolean;
Begin
Result := GetTextAt(158, 367, 0, 3, 4, 128, 0, 3, 'CharsNPC') = 'What';
End;

Wanted

2010-03-01 13:53:57

Result := (Pos(GetTextAt(158, 367, 0, 0, 0, 128, 0, 4, 'CharsNPC'), 'What') > 0);

What you're using will only result true if the EXACT result is 'What' no longer or shorter ect…

bugger0001

2010-03-01 14:02:51

Well, shouldn't the length parameter take care of the comparison problem? Actually that's more or less a pseudo problem but I was more concerned about the fact that at first GetTextAt started up using wrong parameters and, even after going to correct coordinates and font, it still got a few parameters wrong. The fact that the output is not exact is nothing :P

EDIT: Actually the excess letter 'h' comes in because the for loop checking the text in ocr.pas line 792 is following:
for i := 0 to min(high(STPA),len) do
Therefore if i'm setting len=4 then I get 5 letters(0,1,2,3,4) not 4 ;)

mastaraymond

2010-03-01 14:09:49

You should avoid GetTextAt in most cases anyway ;-). Especially if you are searching for a certain 'text'.

GetTextAt should only be used for actual text grabbing (for example chat, or player names, levels etc).

But yeah, not sure why it results the wrong.. A screenshot might help ;-). Besides, does this work in SCAR?

bugger0001

2010-03-01 14:14:52

Scar's GetTextAt has a bit different parameters, but if set up properly then Scar's works well ;)
EDIT: This happens when I'm trying to detect smeltscreen.

Wizzup?

2010-03-01 14:15:02

You may be passing the wrong coordinates. Or the text may move a bit.

bugger0001

2010-03-01 14:19:22

Hmm…Could be, although I tried this a couple of times and it always did the exact same amount of grabbings with wrong parameters before turning to the 'almost' correct parameters.

mastaraymond

2010-03-01 14:19:30

From: bugger0001
Scar's GetTextAt has a bit different parameters, but if set up properly then Scar's works well ;)
EDIT: This happens when I'm trying to detect smeltscreen.

I guess you're using wrong parameters ;-). See the Simba.simb file in the SRL-repos, you can see how to "convert" your SCAR GetTextAtEx to the Simba GetTextAt.

(I see that you are using minspacing 0 and maxspacing 0, for example that cannot be right :p)

bugger0001

2010-03-01 14:24:48

Ok, I'm gonna dig into it :p

EDIT: Yup, you are absolutely right about this one. Not 100% though…MinSpacing can be 0, because GetUpTextAt increments 1 to it :p
Anyways after setting MaxSpacing=3 and hspacing=4 and len=3(because I needed 4 letters) I got a bit better results:
[9, 443, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: Jannick275: > ? > ? >
[9, 429, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: You haven't received? any messages to which you can reply
[9, 415, 0, 3, 4, 0, 0, 80, 'SmallChars']
GetTextAt result: Welcome to RuneScape
and after that BOOM! Got the correct result. Re-tried it 3 times and it always worked pretty much the same - while no smeltscreen up it outputted chat text by automatically reconfiguring the parameters and if smeltscreen came up it outputted the correct string.
Great! Although I'd prefer if the parameter 'len' could be the same as in SCAR's case where it was the number of letters the function would output. Currently it's not length for anything, it's just telling on which index we end the for loop…