# Thread: Autocoloring / Object finding using TAutoColorInfo(TAI).

1. ## Autocoloring / Object finding using TAutoColorInfo(TAI).

As of SRL rev #18 we have a record in SRL called TAutoColorInfo. Basically this records holds a lot of parameters, which some functions can use to auto color or find an object.

As of rev #18 the TAutoColorInfo record looks like this :

SCAR Code:
type  TAutoColorInfo = record    Name: string;    Color: Integer;    MinCount: Integer;    MaxCount: Integer;    MaxDist: Integer;    MaxDistCenter: Integer;    UpText: string;    HueMod, SatMod: Extended;    LumTol: Integer;    MinR, MaxR, MinG, MaxG, MinB, MaxB: Integer;    MinX, MaxX, MinY, MaxY, MinZ, MaxZ: Extended;end;

For those of you that do not know what a record is I suggest you read this tutorial

Basically we throw so many parameters at the function that you pretty much only get the color you want.

*note : just because TAutoColorInfo can contain all these values doesn't mean you have to fill them all in. However you do have to fill in most of them.

Using a TAutoColorInfo
Using a TAutoColorInfo is very simple and quick when you know what to do. Once you have loaded your TAutoColorInfo you can use it in any of the following functions :

Code:
function FindObjRecordEx(var  fx, fy: Integer; AutoInfo: AutoColorInfo; QuickSorting, RGBXYZCheck: Boolean): Boolean;
function FindObjRecord(var  fx, fy: Integer; AutoInfo: TAutoColorInfo): Boolean;
function FindColorRecordEx(var  rx, ry: Integer; ColorRecord: TAutoColorInfo; x1, y1, x2, y2: Integer; RGBXYZCheck: Boolean): Integer;
function FindColorRecord(var  rx, ry: Integer; ColorRecord: TAutoColorInfo): Integer;
*QuickSorting : With QuickSorting on the function divides the TPoints it found using TPAtoATPA, otherwise it uses SplitTPA. TPAtoATPA splits the points by taking one point, create a box around it and any point within that box belongs to that division. SplitTPA first looks at the first point, creates a box around it, much like TPAtoATPA, but then it looks at the second point in that division, creates a box around it, third point ... etc.

*RGBXYZCheck : With this on, it also checks the RGB and XYZ values, instead of just the HSL values.

SCAR Code:
program FindColorRecordExample;{.include SRL\SRL.scar}var  x, y: Integer;  ColorRecord: TAutoColorInfo;begin  SetupSRL;  with ColorRecord do  begin    Name := 'Varrock Road';    MinCount := 100;    Color := 7633790;    HueMod := 0.63;    SatMod := 0.11;    LumTol := 8;    MinR := 106; MaxR := 146;    MinG := 102; MaxG := 144;    MinB := 97; MaxB := 136;    MinX := 13.10; MaxX := 25.89;    MinY := 13.69; MaxY := 27.43;    MinZ := 13.49; MaxZ := 26.86;  end;  Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));end.

Yes it is as easy as that, create your TAI (TAutoColorInfo) variable, load it and use the function. Here follows another example for finding the ladder on the main screen :

SCAR Code:
program FindObjRecordExample;{.include SRL\SRL.scar}var  x, y: Integer;  ObjectRecord: TAutoColorInfo;begin  SetupSRL;  with ObjectRecord do  begin    Name := 'Main Screen Ladder';    UpText := 'Climb';    MaxDist := 15;    Color := 2838120;    HueMod := 0.09;    SatMod := 1.55;    LumTol := 4;    MinR := 95; MaxR := 122;    MinG := 69; MaxG := 90;    MinB := 33; MaxB := 53;    MinX := 7.28; MaxX := 11.91;    MinY := 6.96; MaxY := 11.41;    MinZ := 2.46; MaxZ := 4.71;  end;  FindObjRecord(x, y, ObjectRecord);end.

*tip : Loading a TAI everytime you want to use it does not look very clean. It is advised to load it once globally, much like you load some bitmaps globally.

Creating a TAI
Now you might think how in the world am I supposed to get all those values . I agree, getting those manually is a pain in the *ss so I added a new function in ACA (AutoColorAid) that does the trick for you. If you have SRL rev#18 on your pc, in the standard location, ACA should be located here : C:\Program Files\SCAR 3.15\Includes\SRL\Scripting Tools\Auto Color Aid v2.exe . Unfamiliar with ACA ? Read this.

You simply follow the instructions in that thread but instead of creating a function you create a TAI through the FindColorRecord or FindObjRecord tabs.

TAI's in SRL
TAI's are already being used in SRL. The frog cave solver for examples uses some TAI's. This is all fine and dandy to know, but I guess it is hardly of any interest to you, what you however might like to know is the TAI's I've put in Mining.scar. There are 2 functions in Mining.scar,

Code:
function  FindObjRockEx(var cx, cy: Integer; RockIndex: Integer; QuickSorting, RGBXYZCheck: Boolean): Boolean;
function  FindObjRock(var cx, cy: Integer; RockIndex: Integer): Boolean;
You can use these using a couple of set TAutoColorInfo's in Mining.scar, just by telling what rock you want it to mine . Take a look at this script for example :

SCAR Code:
program New;{.include SRL\SRL.scar}{.include SRL\SRL\skill\Mining.scar}var  x, y: Integer;  begin  SetupSRL  SetupMining;    FindObjRock(x, y, rimmington_Iron);end.

That will find rimmington iron rocks. Here is the list with all possible entries for the rock index (in the example this is rimmington_Iron) :

Code:
  rimmington_Clay
rimmington_Copper
rimmington_Tin
rimmington_Iron
rimmington_Gold

old_Clay
old_Copper
old_Tin
old_Iron
old_Coal
old_Mithril

varrock_Clay
varrock_Copper
varrock_Tin
varrock_Iron
varrock_Silver

lumbridge_Copper
lumbridge_Tin
lumbridge_Coal
lumbridge_Mithril

falador_Adamant
I can imagine all of this may sound a bit like a foreign language to some people, if you need any clarification on some topic please do post here and I will adjust the tutorial.

2. Amazing! Thanks SRL Dev and Sumilion! Looks like I can test this out on my upcomming Power Or Bank Multi - Mine! You guys are AWSOME!

3. wow that is just what i need for lumby stairs!
E: You need to update ACA?

4. Originally Posted by Rubix
wow that is just what i need for lumby stairs!
E: You need to update ACA?
Yeh the one that is in rev #17 or the one that you can download here on the forums will not have this function.

5. what with the mincount and lumtol? i know part of lumtol means tolerance =p

6. SRL Member
Join Date
Apr 2007
Location
The Netherlands
Posts
5,563
Mentioned
0 Post(s)
Quoted
0 Post(s)
GOOD Job Mate, Damn Good Job!

7. without this, i wouldnt have been able to finish my flax spinner :P finds the stairs, the spinning wheel, and even finds the "spin bowstring" button 1337

8. Originally Posted by deathscytex
what with the mincount and lumtol? i know part of lumtol means tolerance =p
LumTol = LumTol
HueTol = HueMod * LumTol
SatTol = SatMod * LumTol

familiar with the HSL color range ? If not I suggest searching for a tutorial here.

Mincount is the minimum amount of pixels an object should have before it will move the mouse to it, or the minimum amount something must have before it is a valid color (in FindColorRecord(Ex)).

9. Banned
Join Date
Oct 2007
Location
If (Online) then Loc := ('On comp') else Loc := ('Somewhere else!');
Posts
2,020
Mentioned
0 Post(s)
Quoted
0 Post(s)
wow very nice and very hand

good job man

10. This will be fun to work with, good job!

11. SRL Member
Join Date
Apr 2007
Location
The Netherlands
Posts
5,563
Mentioned
0 Post(s)
Quoted
0 Post(s)
LOL, i don't got ACA <TheNEwestVErsion> in my scripting tools =/

12. Originally Posted by Hermpie
LOL, i don't got ACA <TheNEwestVErsion> in my scripting tools =/
Delete SRL Folder && checkout SVN.

Epic tut Sumilionio.

13. I made this without the ACA. (I used the old ACA before i foudn out there was ACA V2)

SCAR Code:
function LightingPoint : Boolean;var  x, y : Integer;  ColorRecord : TAutoColorInfo;begin  if (not (LoggedIn)) then Exit;  with ColorRecord do  begin    Name := 'Camelot Road';    MinCount := 50;    Color := 7697533;    HueMod := 0;    SatMod := 0;    LumTol := 5;    MinR := 42; MaxR := 82;    MinG := 52; MaxG := 92;    MinB := 6; MaxB := 46;    MinX := -10; MaxX := 20;    MinY := -9; MaxY := 21;    MinZ := -13; MaxZ := 17;  end;  Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));  if (FindColorRecord(x, y, ColorRecord) = 0) then LogOut;  RoadColor := FindColorRecord(x, y, ColorRecord);  RadialRoadWalk(RoadColor, 160, 190, 62, 1, 1);  FFlag(2);  Wait(330 + Random(275));  Result := True;end;

Well, I put this on my Maple Forest Fire (Woodcutting Maples, FireMaking). Im trying to walk to the Road in Camelot... And lets just say... This TAutoColor was not much of a help... Unless you can find any errors in this function much? Because this is what appears in my DeBug.

****** ******
Creating the NickTPA.
0
________________________________________
[ ]
[ Maple Forest Fire Progress ]
[ Report Version 1 ]
[ Time Elapsed : 1 Minutes and 1 Seconds
[ Ents Found : 0
[ Please Post This Report! ]
[______________________________________]
******* *******
0
So it kept finding 0, so i made the script LogOut the character so the colours refresh. Than at the third try, it failed, but i stopped the script and checked the Road Color just to be sure.

Color Picked: 7500411 at (651, 105)
........ The color i specified shouldve been close enough to the new Road Color.... Did i do something wrong?!

14. XYZ range from 0 to 100, they never go negative.

15. Great tutorial. Can you please elaborate on the following values, please?
QuickSorting
RGBXYZCheck

Thanks. This will definately help in my tutorial island script.

~Macro

16. Originally Posted by Wizzup?
XYZ range from 0 to 100, they never go negative.

-20 for RGB
-15 XYZ
-10 for i forgot the other one, HSL i think.

But thanks Wizzup?!

17. Originally Posted by Macro_FTW
QuickSorting
RGBXYZCheck

Thanks. This will definately help in my tutorial island script.

~Macro
With QuickSorting set to true, the function uses ararP := TPAtoATPA(arAP, MaxDist). Otherwise, it uses ararP := SplitTPA(arAP, MaxDist);. TPAtoATPA groups the points in the array into boxes of the given MaxDist (box dimensions) while SplitTPA groups the points that are a certain maximum distance apart from each other.

The RGBXYZCheck just allows the function to narrow down the points in the array to be more accurate. It would probably be best to leave that on, especially if you're trying to find an object like a rock (using FindObjRock for example).

18. Originally Posted by deathscytex
I made this without the ACA. (I used the old ACA before i foudn out there was ACA V2)

SCAR Code:
function LightingPoint : Boolean;var  x, y : Integer;  ColorRecord : TAutoColorInfo;begin  if (not (LoggedIn)) then Exit;  with ColorRecord do  begin    Name := 'Camelot Road';    MinCount := 50;    Color := 7697533;    HueMod := 0;    SatMod := 0;    LumTol := 5;    MinR := 42; MaxR := 82;    MinG := 52; MaxG := 92;    MinB := 6; MaxB := 46;    MinX := -10; MaxX := 20;    MinY := -9; MaxY := 21;    MinZ := -13; MaxZ := 17;  end;  Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));  if (FindColorRecord(x, y, ColorRecord) = 0) then LogOut;  RoadColor := FindColorRecord(x, y, ColorRecord);  RadialRoadWalk(RoadColor, 160, 190, 62, 1, 1);  FFlag(2);  Wait(330 + Random(275));  Result := True;end;

Well, I put this on my Maple Forest Fire (Woodcutting Maples, FireMaking). Im trying to walk to the Road in Camelot... And lets just say... This TAutoColor was not much of a help... Unless you can find any errors in this function much? Because this is what appears in my DeBug.

So it kept finding 0, so i made the script LogOut the character so the colours refresh. Than at the third try, it failed, but i stopped the script and checked the Road Color just to be sure.

........ The color i specified shouldve been close enough to the new Road Color.... Did i do something wrong?!
Yes I'd suggest recreating the TAI using ACA v2 cause that TAI is just not right. Not only the XYZ are negatives, but the Hue and Sat mods are 0, which means Hue Tolerance is 0 and Saturation Tolerance is 0, which in turn means it will not find many colors, most likely only 7697533 and if it won't find any color it returns 0.

Originally Posted by Macro_FTW
QuickSorting
RGBXYZCheck

Thanks. This will definately help in my tutorial island script.

~Macro
Originally Posted by Method
With QuickSorting set to true, the function uses ararP := TPAtoATPA(arAP, MaxDist). Otherwise, it uses ararP := SplitTPA(arAP, MaxDist);. TPAtoATPA groups the points in the array into boxes of the given MaxDist (box dimensions) while SplitTPA groups the points that are a certain maximum distance apart from each other.

The RGBXYZCheck just allows the function to narrow down the points in the array to be more accurate. It would probably be best to leave that on, especially if you're trying to find an object like a rock (using FindObjRock for example).
He is right, I also added a small explanation at the first post about it.

19. Well Sumilion. problem is with the ACA V2, when i click on the road color, the huemod is 0 and etc.

20. Originally Posted by deathscytex
Well Sumilion. problem is with the ACA V2, when i click on the road color, the huemod is 0 and etc.
True, then you have only selected one color. The power of ACA lies in the ability to take the average from all the colors you've put in, and calculate what tol it needs to be similar to each color you've put in. So the more colors you've entered in ACA, the bigger the chance it will find the color you want. You're using ACA to find the road color ? I suggest going into a world, pick the road color, logout + login, pick it again, switch worlds and repeat.

21. Oh, thanks Sumilion! I'll see you in the SRL Application Forms soon.

22. Originally Posted by deathscytex
Oh, thanks Sumilion! I'll see you in the SRL Application Forms soon.
Will you now ? glad I could help

23. Retired Developer
Join Date
Mar 2007
Posts
1,699
Mentioned
0 Post(s)
Quoted
8 Post(s)
What's the advantage of using this over normal autocoloring/object finding?

24. Its fast to make and easily adjustable.

25. Is it the same reliability as a regular Auto Color?

And also, i got accepted in SRL Members! Check me out! Look so cool. (You can see the difference =3)