Log in

View Full Version : Finding Text



TheGodfather
02-15-2007, 05:57 AM
Say if im Mining, I want it to check if the letters 'ine' are up at the top left corner. What Function what I use to Check if 'ine' = true?

Dark_Sniper
02-15-2007, 05:58 AM
if isuptext('ine') then begin
whatever you going to do after you find the text.
end;

TheGodfather
02-15-2007, 06:06 AM
thanks ;)
Thats SRL right?

Dark_Sniper
02-15-2007, 06:08 AM
yes same with
Option2('ine')

IsUpTextMulti is cool cause you can go like

IsUpTextMulti('ine', 'Mine', 'in') stuff like that see now it checks for it 3 times instead of once.

the flea
02-15-2007, 08:29 PM
oh wow thanx dark sniper untill now ive been using bitmaps. well time to update the script im making to apply for srl membership.

roM3
02-19-2007, 10:24 AM
I got question about istext function too...It can use for any color of text?Or for certain color?

Buckleyindahouse
02-19-2007, 11:23 AM
I got question about istext function too...It can use for any color of text?Or for certain color?

I don't think so, I know it searches for the text.

Smartzkid
02-19-2007, 09:19 PM
Is there a way to find out what color the text is? Something that I could use to protect from ents....

n3ss3s
02-20-2007, 08:02 PM
SmartzKid here is answer for ur problem. this is srl too.


function GetTextColor(var x,y:integer;txt:string;font,xx,xy,sx,sy:integer):b oolean;
{ Gets the specified text's color in a specified box. by villu-reborn.org n3ss3s / sythe.org 1337snak3 }
var a:integer;
begin
if(findtext(x,y,txt,font,xx,xy,sx,sy)) then
begin
mmouse(x,y,0,0);
getmousepos(x,y);
a:=getcolor(x,y);
writeln('Text-color picked at'+inttostr(x)+','+inttostr(y)+' : '+inttostr(a));
end;
end;

made this quickly. It should work. But you need to solve what are the fonts in findtext. I have no idea about font:integer; why is it integer? However
ZOMG DID I JUST MAKE A FUNCTION FIT FOR SRL??!!!
If someone of u developers like , spit it to srl.
This function was made 10.02 pm 20.02.2007!! if u ppl use remember to keep the credit thingy in there! ;D

Smartzkid
02-20-2007, 08:47 PM
function GetTextColor(var x,y:integer;txt:string;font,xx,xy,sx,sy:integer):b oolean;
{ Gets the specified text's color in a specified box. by villu-reborn.org n3ss3s / sythe.org 1337snak3 }
var a:integer;
begin
if(findtext(x,y,txt,font,xx,xy,sx,sy)) then
begin
//mmouse(x,y,0,0); <--I dont think you need either of these lines
//getmousepos(x,y); <--
a:=getcolor(x,y);
writeln('Text-color picked at'+inttostr(x)+','+inttostr(y)+' : '+inttostr(a));
end;
end;

also; why does it say it should return a boolean, when it really doesn't return anything?

Thanks though; I think I'll mod it to fit my needs =)

WT-Fakawi
02-20-2007, 09:43 PM
The Function you are looking for is SCAR, not SRL!


function GetTextAtEx(x, y: Integer; Tolerance: Integer; Chars: Integer; CheckShadow, CheckOutline: Boolean; MinSpacing, MaxSpacing: Integer; TextColor: Integer; TextLength: Integer; Strict: Boolean; Range: TCharRange): string;
Reads text at position specified by x, y. Tolerance specifies acceptable color range in for characters that are not completely monochrome, Chars specifies font number returned by LoadChars2 or LoadCharsFromFont2, CheckShadow specifies whether function should look for shadow, CheckOutline specifies whether function should verify if character borders are correct, MinSpacing and MaxSpacing are RS1 and RS2 specific parameters for text with changing spacing between characters, in other cases use MinSpacing=0 and MaxSpacing=0, TextColor specifies text color, if set to -1, will search for text in any color, TextLength - maximal text length to read, if Strict is set to true then it won't find characters that contain additional pixels of character's color in the same area as character is, Range can have following values:
tr_AllChars - read all characters;
tr_BigLetters - read capital Latin letters;
tr_SmallLetters - read lowercase Latin letters;
tr_Digits - read digits;
tr_BigSymbols - read symbols that are big in size, like "=", "%", "$", etc;
tr_SmallSymbols - read small symbols like ".", ",", "'", etc;
tr_SecondTableChars - read symbols with character code above 127;
tr_Letters = tr_BigLetters or tr_SmallLetters;
tr_AlphaNumericChars = tr_Letters or tr_Digits;
tr_Symbols = tr_BigSymbols or tr_SmallSymbols;
tr_NormalChars = tr_AlphaNumericChars or tr_Symbols;
Example:
GetTextAtEx(9, 9, 130, UpChars, True, False, 0, 1, $E0E0E0, 20, False, tr_AlphaNumericChars) - read RS2 upper text in this color.
GetTextAtEx(96, 387, 0, ChatChars, False, False, 0, 0, -1, 20, True, tr_NormalChars) - read RS2 chat text in any color.
UpChars and ChatChars are set up during script initialization like this:
UpChars := LoadChars2(AppPath + 'CharsRS22\');
ChatChars := LoadChars2(AppPath + 'CharsChat2\');


As you can see you can input a specific Color :)



or...

function IsTextAtEx(x, y: Integer; S: string; Tolerance: Integer; Chars: Integer; CheckShadow, CheckOutline: Boolean; MinSpacing, MaxSpacing: Integer; TextColor: Integer): Boolean;
Checks if text specified by S is at location specified by x, y. Tolerance specifies acceptable color range in case characters are not completely monochrome, Chars specifies font number returned by LoadChars2 or LoadCharsFromFont2, CheckShadow specifies whether function should look for shadow, CheckOutline specifies whether function should verify if character borders are correct, MinSpacing and MaxSpacing are RS1 and RS2 specific parameters for text with changing spacing between characters, in other cases use MinSpacing=0 and MaxSpacing=0, TextColor specifies text color, if set to -1, will search for text in any color.

function IsTextInAreaEx(x1, y1, x2, y2: Integer; var x, y: Integer; S: string; Tolerance: Integer; Chars: Integer; CheckShadow, CheckOutline: Boolean; MinSpacing, MaxSpacing: Integer; TextColor: Integer): Boolean;
Searches for text in area specified by x1, y1, x2, y2. Other parameters match IsTextAtEx.


thus:


function IsUpText(UpText: string): Boolean;
var
tempx, tempy: Integer;
begin
Result :=IsTextInAreaEx(7, 7, 334, 20, tempx, tempy, UpText, 100, upchars, True,
True, 0, 2, -1)) ;
end;

checks for any Upperleft Colored text

Smartzkid
02-20-2007, 09:59 PM
so...would:


function IsYellowText(UpText: string): Boolean;
var
tempx, tempy: Integer;
begin
Result :=IsTextInAreaEx(7, 7, 334, 20, tempx, tempy, UpText, 100, upchars, True,
True, 0, 2, 117965)) ;
end;

Search for yellow text? Is it possible to set a tolerance? Or should I just loop it and change the color a bit each time?

n3ss3s
02-25-2007, 05:41 PM
OMG! Kneel To Wt-fakawi! I think ur version pwns mine , hehe :D

This may be good for some other situation, dont know...

function GetTextColor(var x,y:integer;txt:string;font,xx,xy,sx,sy:integer):b oolean;
{ Gets the specified text's color in a specified box. by villu-reborn.org n3ss3s / sythe.org 1337snak3 }
var a:integer;
begin
if(findtext(x,y,txt,font,xx,xy,sx,sy)) then
begin
mmouse(x,y,0,0);
getmousepos(x,y);
a:=getcolor(x,y);
writeln('Text-color picked at'+inttostr(x)+','+inttostr(y)+' : '+inttostr(a));
Result:=a;
end;
end;