SRL Archive - Help and Support

How do I use IsTextAt2() ?


Ron

2007-01-08 23:39:13

I tried using this code when I was in RS today, but it didn't seem to work properly when I hovered my mouse above anything that began with "Attack". :(


program TestIsTextAt2;

{.include SRL\SRL.scar}

begin
ClearDebug;
SetupSRL;
repeat
if(IsTextAt2(9, 9, 'Attack', 100))then
WriteLn('"Attack" text has been found in the top left corner!');
wait(100);
until(isfkeydown(12))
end.

What did I do wrong?

tarajunky

2007-01-08 23:49:17

There are many possibilities. One is that SCAR simply didn't see the white text you specified, perhaps due to a white-ish background behind it.

You should use IsUpText or IsUpTextMulti. It works well, even though it occasionally has the same 'background interference' problem.

Yakman

2007-01-09 02:11:02

to use IsTextAt2 you need to load the RS2 chars, do

LoadChars('');

Wizzup?

2007-01-09 02:41:08

Tip:

Use IsUpText.

Lorax

2007-01-09 04:26:38

IsTextAt2 is to old, I agree with the rest - use IsUpText, but another thing is that you shouldn't search for Capital letter, search 'ttack' instead of 'Attack' that would perhaps make IsTextAt2 work, but still I don't suggest working on it..

WT-Fakawi

2007-01-09 05:02:00

Or IsUpText('tt'). There is a significant reduce in the amount of cycles when you reduce the OCR to a minimun.

You could also use GetTextAtEx, it is SCAR's fastest text->bitmap->ascii conveter (IsUpText uses GetTextAtEx)

Lorax

2007-01-09 05:46:33

From: WT-Fakawi
Or IsUpText('tt'). There is a significant reduce in the amount of cycles when you reduce the OCR to a minimun.

You could also use GetTextAtEx, it is SCAR's fastest text->bitmap->ascii conveter (IsUpText uses GetTextAtEx)


Yes it's allways good to reduce the most system demanding procedures, I found that when reducing your laag, Waits normally don't do much - but they do same - they have to be there - but using procedures that are less systemdemanding is the trick - ExistsItem instead of InvCount and such..
That's why I don't search for chat text - or if I do then I use GetColor, GetColor, GetColor — a few of these ..

Ron

2007-01-09 15:49:02

Hey! IsTextUp worked great!

Here is a test script I made in the lumby chicken pen.


program TestInChickenPen;

{.include SRL\SRL.scar}

begin
ClearDebug;
SetupSRL;
ActivateClient;
repeat
if(IsUpText('tt'))then
WriteLn('Attack was found!')
else if(IsUpText('one'))then
WriteLn('Time to bury!')
else if(IsUpText('aw'))then
WriteLn('Cook that chicken!')
else if(IsUpText('ake'))then
WriteLn('TAKE IT!');
wait(100);
until(isfkeydown(12))
end.

~Ron

tarajunky

2007-01-09 15:50:09

Sometimes just finding the appropriate color at the top of the screen is enough. :)

For instance if you want to pick up something, the text is going to be blue for items. Or if you want to attack something, the text will be yellow for a monster.

Like if you're using Ratz and you're planning to drop all the crap you pick up anyway, then it doesn't really matter what you're picking up, does it? You can search for a bone or whatever and just pick up anything that is found by the first simple search. If it's not a bone you can drop it later anyway, so it's no big deal.

Ron

2007-01-09 16:01:11

So if I wanted to find the text "fishalflazz" and it was in red, 255, so then would i use GetTextATEx() or what? Sorry, I don't really understand. :(

Btw, thank you so much for all the help everyone.

Cheesehunk

2007-01-09 18:24:02

From: Ron
So if I wanted to find the text "fishalflazz" and it was in red, 255, so then would i use GetTextATEx() or what? Sorry, I don't really understand. :(

I'm pretty sure he just means to a FindColor or a FindColorSpiral or something in the top left corner. I don't know much about GetTextAtEx, I only use it for static letters (Letters that stay in the same place, such as in trade screen.) Also, the chances are, if you are creating a text function for searching Up text, it's already somewhere in SRL. I'm pretty sure there are a couple in the extended are as well.

tarajunky

2007-01-09 18:29:13

DTMs are the best for text finding, IMO.

You can add area tolerance to account for the shifts in text spacing. And you can increase the color tolerance by huge amounts to eliminate colorchanges due to background. And of course you are searching in a small, defined area, so they can be very specific, reliable, and fast.

The -big- downside to using DTMs is that you have to create and tweaks every one of them for every specific bit of text you want to find.

Ron

2007-01-10 16:10:25

From: tarajunky
DTMs are the best for text finding, IMO.
The -big- downside to using DTMs is that you have to create and tweaks every one of them for every specific bit of text you want to find.


That's a real nasty downside man. :( Even with that downside, is it still better than that Up Text function previously suggested?

tarajunky

2007-01-10 16:59:45

To answer your question, let me give you and example. In my chickenkiller I kill thousands and thousands of chickens. It's always chickens and never any other kind of monster.

Since the chickenfinding procedures are pretty good, the text should USUALLY be right. The way I check is to use IsTextAt2 for Attack. If that fails, then I check for the monster name with IsUpText. If that fails, then I check with a DTM.


if not(IsTextAt2(9,9,'Attack '+MonsterName,100)) then
begin
if not(IsUpText(MonsterName)) then
begin
ChickenText:=DTMFromString('78DA63B4616060E0644001AF5F72314401694' +
'620FE0F048C764086106E3520C0E882300726F6F6350FA61A5E54' +
'73EEDE614255138250C304157BFF8607538D100135200E1FAA9AB' +
'B779851D4000017CD15CF');
if not(FindDTM(ChickenText,tmpx1,tmpy1,15,5,260,40)) then
begin
FreeDTM(ChickenText);
Result:=False;
Exit;
end else FreeDTM(ChickenText);
end;
end;

In other words, you can use multiple tiers of textfinding if you want. If it finds the text on the first pass it skips the rest so you're no worse off. If it doesn't find it on the first check, try another.

WT-Fakawi

2007-01-10 18:32:57

The trick is indeed to use multiple method to get things done. There are a couple of common methods of finding objects:

  1. Scanning for its color.
  2. Scanning for a Colored Area.
  3. Scanning for a Bitmap of an Object.
  4. Scanning for a Bitmap Mask.
  5. Scanning for a Deformed Bitmap.
  6. Scanning using DTM's.


1. Scanning for a Color.

Needed for fast moving objects, like Goblins and Chickens.
Use: FindColor, FindColorTolerance, , FindColorSpiral, FindColorSpiralTolerance.


2. Scanning for a Colored Area.

Used for slower moving objects, like cows. But can also be used for furnaces, doors, etc.
Use: FindColoredAreaTolerance, FindColorsSpiralTolerance.


3. Scanning for a Bitmap.

This is only useful for Inventory and MiniMap. RS-Items are static objects. Their color and shape are fixed.
Use: FindBitmapIn, FindBitmapToleranceIn, RotateBitmap.


4. Scanning for a Deformed Bitmap.

This is one the most interesting functions in Scar, but rather underestimated by the majority of Scripters. Deformed Bitmaps are scanned using their shape as opposed to their color. Its a unique function and very powerful. You can use it to find trees, banks, npcs, agility objects etc. I always use slices of bitmaps as Deformed Bitmaps. (8 x 1) or (1x 17) . Its perfomance is rather sluggish (lags) but it is a stable way for finding objects.
Use: FindDeformedBitmapToleranceIn( FindDeformedBitmapToleranceRotationIn


5. Scanning using DTM's.

DTM's are collections of colored pixels with a fixed color/place relation, not unlike like a spiderweb. They are useful for anything really, as long as the colors are more or less stable and the relation 100% fixed, like Bitmaps.
They are rather cumbersome to create and you really need a slow mouse to set the anchorpoints right.
Use: FindDTM.

WT-Fakawi

2007-01-10 18:33:23

The trick is indeed to use multiple method to get things done. There are a couple of common methods of finding objects:

  1. Scanning for its color.
  2. Scanning for a Colored Area.
  3. Scanning for a Bitmap of an Object.
  4. Scanning for a Bitmap Mask.
  5. Scanning for a Deformed Bitmap.
  6. Scanning using DTM's.


1. Scanning for a Color.

Needed for fast moving objects, like Goblins and Chickens.
Use: FindColor, FindColorTolerance, , FindColorSpiral, FindColorSpiralTolerance.


2. Scanning for a Colored Area.

Used for slower moving objects, like cows. But can also be used for furnaces, doors, etc.
Use: FindColoredAreaTolerance, FindColorsSpiralTolerance.


3. Scanning for a Bitmap.

This is only useful for Inventory and MiniMap. RS-Items are static objects. Their color and shape are fixed.
Use: FindBitmapIn, FindBitmapToleranceIn, RotateBitmap.


4. Scanning for a Deformed Bitmap.

This is one the most interesting functions in Scar, but rather underestimated by the majority of Scripters. Deformed Bitmaps are scanned using their shape as opposed to their color. Its a unique function and very powerful. You can use it to find trees, banks, npcs, agility objects etc. I always use slices of bitmaps as Deformed Bitmaps. (8 x 1) or (1x 17) . Its perfomance is rather sluggish (lags) but it is a stable way for finding objects.
Use: FindDeformedBitmapToleranceIn( FindDeformedBitmapToleranceRotationIn


5. Scanning using DTM's.

DTM's are collections of colored pixels with a fixed color/place relation, not unlike like a spiderweb. They are useful for anything really, as long as the colors are more or less stable and the relation 100% fixed, like Bitmaps.
They are rather cumbersome to create and you really need a slow mouse to set the anchorpoints right.
Use: FindDTM.

Boreas

2007-01-10 19:29:18

The ABC's of scripting. Have a plan A, a plan B, a plan C..