SRL Archive - OSR Help

need help with this function/procedure


Here2help

2012-05-21 19:05:25

function A_FindObj(color, tol, count : integer; uptext : string; left : boolean): Boolean;
var
X, Y, A, M, curCTS: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
Result := False;
if not LoggedIn then exit;
curCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, tol) then
begin
ColorToleranceSpeed(1);
writeln('Cannot find color');
exit;
end;
ColorToleranceSpeed(1);
ATPA := TPAtoATPAEx(TPA, 10, 10);
M := High(ATPA);
for A := 0 to M do
begin
if Length(ATPA[A]) < count then
continue;
if MiddleTPAEx(ATPA[A], X, Y) then
begin
MMouse(X, Y, 6, 6);
Wait(100 + Random(50));
if WaitUptext(uptext, 100) then
begin
GetMousePos(X, Y);

Mouse(X, Y, 0, 0, left);
Result := True;
ColorToleranceSpeed(curCTS);
Exit;
end;
end;
end;
ColorToleranceSpeed(curCTS);
end;

I'm trying to use this to detect the range in catherby. And this is what i have so far.

procedure clickthisitem;
begin
mouseitem(1, 0);
end;
function if A_FindObj(rangecol, 10, 10, 'ange', true) then
var
X, Y, A, M, curCTS: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
Result := False;
if not LoggedIn then exit;
curCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2962580, 5339537, MSX1, MSY1, MSX2, MSY2, tol) then
begin
ColorToleranceSpeed(1);
writeln('Cannot find color');
exit;
end;
ColorToleranceSpeed(1);
ATPA := TPAtoATPAEx(TPA, 10, 10);
M := High(ATPA);
for A := 0 to M do
begin
if Length(ATPA[A]) < count then
continue;
if MiddleTPAEx(ATPA[A], X, Y) then
begin
MMouse(X, Y, 6, 6);
Wait(100 + Random(50));
if WaitUptext(uptext, 100) then
begin
GetMousePos(X, Y);

Mouse(X, Y, 0, 0, left);
Result := True;
ColorToleranceSpeed(curCTS);
Exit;
end;
end;
end;
ColorToleranceSpeed(curCTS);
end;

I keep getting the error

[Error] (27:10): Identifier expected at line 26


I'm so lost atm…

Here2help

2012-05-21 19:10:08

This is line 26 btw
function if A_FindObj(rangecol, 10, 10, 'ange', true) then

Gucci

2012-05-21 19:10:26

There are major flaws at the beginning there, you have a if..then function as the title of your function. You need to move that else where and you need to specify the type of function I just made it boolean

function FindSomething: Boolean; // This entire area is messed up
if A_FindObj(rangecol, 10, 10, 'ange', true) then //Not sure what your trying to do with this but this is a if..then function
var
X, Y, A, M, curCTS: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
Result := False;
if not LoggedIn then exit;
curCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2962580, 5339537, MSX1, MSY1, MSX2, MSY2, tol) then
begin
ColorToleranceSpeed(1);
writeln('Cannot find color');
exit;
end;
ColorToleranceSpeed(1);
ATPA := TPAtoATPAEx(TPA, 10, 10);
M := High(ATPA);
for A := 0 to M do
begin
if Length(ATPA[A]) < count then
continue;
if MiddleTPAEx(ATPA[A], X, Y) then
begin
MMouse(X, Y, 6, 6);
Wait(100 + Random(50));
if WaitUptext(uptext, 100) then
begin
GetMousePos(X, Y);

Mouse(X, Y, 0, 0, left);
Result := True;
ColorToleranceSpeed(curCTS);
Exit;
end;
end;
end;
ColorToleranceSpeed(curCTS);
end;

Just looks like you have no clue what your doing, I suggest you looks at some beginner tutorials

Here2help

2012-05-21 19:14:10

this whole tpa thing is confusing me.

I was trying to make it find the rage uptext there. Guess I'll head back to the tutorials.

Abu

2012-05-21 19:17:13

Well I hope it was common knowledge that you can't name a function:
if A_FindObj(rangecol, 10, 10, 'ange', true) then

You have to actually give it a name and declare the variables before starting it.

Here2help

2012-05-21 19:21:37

It is now.
lakjsdpofiuasklfoaiuselrkjpaoiufd < – How I feel.