SRL Archive - OSR Help

Finding object problem.


Dervish

2012-06-23 13:43:39


This part of my script is driving me crazy.

Although it clearly doesn't find the sailor, it prints out "Found.". The uptexts are, of course wrong but it still emits a positive result..

Anyone know why ?

Abu

2012-06-23 13:46:36

I've realised as well there's been a problem (very) recently with uptexts…

I use WaitOption() but it just never seems to select the option…

Dervish

2012-06-23 13:57:55

From: abu_jwka
I've realised as well there's been a problem (very) recently with uptexts…

I use WaitOption() but it just never seems to select the option…


My other case :


Works perfectly.. Would it only concern NPC uptexts ?

Brandon

2012-06-23 14:15:55

Happening to me atm.. I just tried running my nature bot.. my god the uptext recognition is totally screwed in castlewars.

Not sure what's causing it but the font is either broken or all the colours changed :S

I use the uptext from my waterfiends script now:


{$I SRL/SRL.Simba}

const
UptextFS = true; //UptextFailSafe

Function FindTextCustom(TextToSearchFor: TStringArray; Box: TBox; Colour, Tolerance: Integer; PrintResult: Boolean; Font: String): boolean;
var
Data: string;
ListOfFonts, AllFonts: TStringArray;
I, J: Integer;
begin
Result:= False;
AllFonts:= ['BigChars', 'CharsNPC', 'CharsTrade', 'FriendChars', 'LoginChars', 'SmallChars', 'SmallCharsNS', 'StatChars', 'UPChars', 'UpCharsEx', 'XPChars'];

if (LowerCase(Font) = 'all') then
ListOfFonts:= AllFonts
else
begin
if (Not InStrArr(Font, AllFonts, false)) then
begin
SRL_WARN('FindTextCustom', 'Invalid Font!', 0);
exit;
end;
ListOfFonts:= [Font];
end;

For J:= 0 To High(ListOfFonts) do
begin
Data:= GetTextAtExWrap(Box.X1, Box.Y1, Box.X2, Box.Y2, 0, 5, 2, Colour, Tolerance, ListOfFonts[J]);
For I:= 0 To High(TextToSearchFor) do
begin
if (TextToSearchFor[I] <> '') then
begin
TextToSearchFor[I] := Replace(TextToSearchFor[I], '?', '.');
Result:= ExecRegExpr('.*'+TextToSearchFor[I]+'.*', Data);
end;

if Result then
begin
If PrintResult then
writeln(Data);
exit;
end;
end;
end;
end;

Function FindAllText(Uptexts: TStringArray; Box: TBox; Colours: TIntegerArray; Tolerance: Integer; PrintResults: Boolean; Font: String): Boolean;
var
I: Integer;
begin
For I:= 0 To High(Colours) do
begin
Result:= FindTextCustom(UpTexts, Box, Colours[I], Tolerance, PrintResults, Font);
If Result then
exit;
end;
end;

Function UptextsBroken(Uptexts: TStringArray): Boolean;
var
ListOfColours: TIntegerArray;
begin
If UptextFS then
begin
try
ListOfColours := [14211799, 6667731, 14672351, 1169359, 2721999, 14212565,
13751822, 14474972, 13816530, 1803484, 2656464, 3249636,
3380704, 2461153, 14803936, 15067364, 13684943, 15198949,
15396073, 15593452, 15659246, 14474460, 6338516, 6207445,
3552820, 8641269, 8181491, 16645627, 183554, 5941953, 184322,
185813];
Result:= FindAllText(Uptexts, IntToBox(5, 9, 338, 23), ListOfColours, 60, True, 'UpChars');
except
Result:= true;
end;
end;
end;

begin
SetupSRL;

If UptextsBroken(['Ring', 'ing']) then
if UptextsBroken(['ele', 'eleport', 'port']) then
begin
//Run some func.
end;
end.

Abu

2012-06-23 14:27:47

From: Dervish


Works perfectly.. Would it only concern NPC uptexts ?


WaitOption() applies to everything.

Dervish

2012-06-23 14:53:35

From: abu_jwka
WaitOption() applies to everything.


I thought waitoption was for choosing an option ? as in right click options. I've come to the conclusion that UpText recognition works for objects but not NPCs.

Abu

2012-06-23 14:55:41

From: Dervish
I thought waitoption was for choosing an option ? as in right click options. I've come to the conclusion that UpText recognition works for objects but not NPCs.


Yes and you can choose an option for almost everything.

Which means it not just uptext(for NPC's), but text recognition which is broken.

Kyle Undefined

2012-06-23 14:56:15

He's thinking of WaitUpText();

Abu

2012-06-23 14:57:04

From: Kyle Undefined
He's thinking of WaitUpText();


If you're talking about me… nope.

WaitOption() is broken for me.

I'll check WaitUpText though…

Dervish

2012-06-23 15:01:21

So all text recognition would be broken..? Quite a grave issue, anything I can do ?

Kyle Undefined

2012-06-23 15:16:46

From: abu_jwka
If you're talking about me… nope.

WaitOption() is broken for me.

I'll check WaitUpText though…


He's not choosing an option, he's finding an Object. WaitOption is pointless to use for that and makes no sense.

Abu

2012-06-23 15:17:41

From: Dervish
So all text recognition would be broken..? Quite a grave issue, anything I can do ?


Take a look at the include and see if you can do anything?
Then send a pull request.

Otherwise wait…

Dervish

2012-06-23 15:29:19

Found a temporary solution for my problem : a DTM of the uptext, simple but it works.

I'm not a good enough scripter to work with text recognition algorithms abu_jwka.

Abu

2012-06-23 15:41:32

From: Kyle Undefined
He's not choosing an option, he's finding an Object. WaitOption is pointless to use for that and makes no sense.


I know that. -_-

I was saying that it's not working for me. I wasn't telling him to use it.

P1ng

2012-06-23 23:10:33

I had a similar problem with finding UpText of items in the bank when I was writing my stringer script, may look into just using DTMs of the UpText if this is happening for alot of people.