Sumilion
07-13-2008, 09:53 PM
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 :
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 (http://www.villavu.com/forum/showthread.php?t=9746?t=10966)
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 :
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.
Loading a TAutoColorInfo is just the same as loading any other record, here is an example of a varrockroad-TAutoColorInfo, using FindColorRecord we get the RoadColor.
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 :
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 :confused:. 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 (http://www.villavu.com/forum/showthread.php?t=26944).
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,
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 :eek:. Take a look at this script for example :
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) :
rimmington_Clay
rimmington_Copper
rimmington_Tin
rimmington_Iron
rimmington_Gold
old_Clay
old_Copper
old_Tin
old_Iron
old_Coal
old_Mithril
old_Adamant
varrock_Clay
varrock_Copper
varrock_Tin
varrock_Iron
varrock_Silver
lumbridge_Copper
lumbridge_Tin
lumbridge_Coal
lumbridge_Mithril
lumbridge_Adamant
falador_Clay
falador_Copper
falador_Tin
falador_Iron
falador_Coal
falador_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.
As of rev #18 the TAutoColorInfo record looks like this :
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 (http://www.villavu.com/forum/showthread.php?t=9746?t=10966)
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 :
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.
Loading a TAutoColorInfo is just the same as loading any other record, here is an example of a varrockroad-TAutoColorInfo, using FindColorRecord we get the RoadColor.
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 :
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 :confused:. 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 (http://www.villavu.com/forum/showthread.php?t=26944).
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,
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 :eek:. Take a look at this script for example :
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) :
rimmington_Clay
rimmington_Copper
rimmington_Tin
rimmington_Iron
rimmington_Gold
old_Clay
old_Copper
old_Tin
old_Iron
old_Coal
old_Mithril
old_Adamant
varrock_Clay
varrock_Copper
varrock_Tin
varrock_Iron
varrock_Silver
lumbridge_Copper
lumbridge_Tin
lumbridge_Coal
lumbridge_Mithril
lumbridge_Adamant
falador_Clay
falador_Copper
falador_Tin
falador_Iron
falador_Coal
falador_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.