SRL Archive - Discussions and Debates

Re-look on obj finding


BazzBarrett

2008-11-11 17:21:00

I realy whanted to start this 40 days ago (u can thank bt for that 1 (Internet was "accudently" cut off)) but now im back ill try and start were i left off :p

Looking in the includes i notice that most of the object finding altough most of it still would most likly work, is mostly unused and some even irelivent.

My main poin is TAutoColorInfo because the whole 5 mounth+ ive been here i havent seen a single script that uses this! so unless there is somthing realy big that i dident see, this is pritty useless. altough there probubly are scripts that use this so i dont know weather it would be worth Removing this or just calling it quits and just adding more relivent newer functions intro the objects.scar file or creating a new include altogether.

I feal all these can pritty much be turned into 1.. id sujest this 1 witch i made but i recon it will need some improvement with u guys cuz im not exsaculy SRL class :p

{*******************************************************************************
function FindObject(Var X, Y :Integer; Color, Tolerance :Integer; UpTextToCheck :String):Boolean;
By: Bazzbarrett
Description: Finds objects using a TPA of the color specified with the
tolerance specified, and then checking the uptext to make
sure we have found the correct object
Parameters:
X, y : Were to store the coordanates of the found object.
Color : The color of your object.
Tolerance : The tolerance to search for the object at i recomend about 15.
UpTextToCheck : Part of the uptext to check if we have the correct object
E.g. 'Oak' or 'tack Cow'
Example: FindObject(TreeX, TreeY, 2777428, 15, 'Oak');
*******************************************************************************}

Function FindObject(Var X, Y : Integer; Color, Tolerance :Integer; UpTextToCheck : String):Boolean;
var
CTS, II, HATPA : Integer;
TPA : TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
HATPA := High(ATPA);
For II := 0 to HATPA do
begin
MiddleTPAEx(ATPA[II], X, Y);
MMouse(X, Y, 2, 2);
Wait(50+Random(10));
If(IsUpText(UpTextToCheck))then
begin
Result := True;
GetMousePos(x, y);
Exit;
end;
end;
end;

please post feedback what u think alternate sujestions anything useful :p

Cazax

2008-11-11 17:34:32

What if the thing you are searching for is less than 15*15 pixels?

BazzBarrett

2008-11-11 17:56:14

From: Cazax
What if the thing you are searching for is less than 15*15 pixels?

I taught it arraged it into 1 location per 15*15 pixs meaning a very rare chance of this failing unless the object is way under 15*15 pixs witch i dnt realy know many things under 15*15 pixs.. i suppose u could create 2 or just change that 2 much smaller digits but incressesing sometimes unessacey searching. my idear for this is for people who only need a quick object finder thats very reliable obviously anything under 15 pixs is going to need something a bit more.

HyperSecret

2008-11-11 20:40:55

FindObjectTPA works pretty nicely.


function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray): Boolean;
var
I, j, tcts: Integer;
myPoint: TPoint;
Points: TPointArray;
aPoints: T2DPointArray;
s: string;
begin
tcts := GetColorToleranceSpeed;
if CTS * 9 mod 3 <> 0 then
CTS := 1;
ColorToleranceSpeed(cts);
FindColorsSpiralTolerance(x, y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
SetLength(Points, 0);
for I := 0 to Length(aPoints) - 1 do
begin
if Length(aPoints[I]) < minCount then
Continue;
myPoint := MiddleTPA(aPoints[I]);
MMouse(myPoint.X, myPoint.Y, 0, 0);
Wait(100 + Random(50));
ColorToleranceSpeed(1);
s := rs_getuptext;
for j := 0 to high(uptext) do
if pos(uptext[j], s) <> 0 then
begin
x := myPoint.X;
y := myPoint.Y;
Result := True;
ColorToleranceSpeed(tcts);
Exit;
end;
ColorToleranceSpeed(cts);
end;
ColorToleranceSpeed(tcts);
end;

I know at least Sumillion and Nielsie Autominer uses the TAutoColorInfo. I would use it if I were to make a new script also. I just think not many people know how to use it and are 'afraid' to use it.

BazzBarrett

2008-11-15 20:45:39

From: HyperSecret
FindObjectTPA works pretty nicely.


function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray): Boolean;
var
I, j, tcts: Integer;
myPoint: TPoint;
Points: TPointArray;
aPoints: T2DPointArray;
s: string;
begin
tcts := GetColorToleranceSpeed;
if CTS * 9 mod 3 <> 0 then
CTS := 1;
ColorToleranceSpeed(cts);
FindColorsSpiralTolerance(x, y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
SetLength(Points, 0);
for I := 0 to Length(aPoints) - 1 do
begin
if Length(aPoints[I]) < minCount then
Continue;
myPoint := MiddleTPA(aPoints[I]);
MMouse(myPoint.X, myPoint.Y, 0, 0);
Wait(100 + Random(50));
ColorToleranceSpeed(1);
s := rs_getuptext;
for j := 0 to high(uptext) do
if pos(uptext[j], s) <> 0 then
begin
x := myPoint.X;
y := myPoint.Y;
Result := True;
ColorToleranceSpeed(tcts);
Exit;
end;
ColorToleranceSpeed(cts);
end;
ColorToleranceSpeed(tcts);
end;

I know at least Sumillion and Nielsie Autominer uses the TAutoColorInfo. I would use it if I were to make a new script also. I just think not many people know how to use it and are 'afraid' to use it.


ok i agree with u that its a good function but like u said its 2 complicated.. thats what i dont like about it. well we could ever try spreading the word (because TPA's are a vital part of rs scripting yet so meny jr. members dont even know wat it means (h)

how about adding a new function FindObject and just uncomplicate findobjTPA

for e.g.

Function FindObject(var x, y: Integer; Color, Tol, Size: Integer; UpText:String): Boolean;
begin
Result := FindObjTPA(x, y, color, tol, 2, Size, Size, 5, [UpText]): Boolean;
//im unsure as to what a gud min count is..
end;

Method

2008-11-15 22:28:33

Why is it "too complicated"? All of the parameters are explained in the comment above the function, and if you're even thinking about using TPAs, you should know what most of them mean anyways.

n3ss3s

2008-11-16 14:11:53

Logic - Removing 'TPA' from the name and saving all the same parameters doesn't make it any less complicated…

BazzBarrett

2008-11-16 17:03:49

fine then.. how about just trying 2 teach people more about it?