SRL Archive - OSR Help

Why is this compiliing but not working?


Wu-Tang Clan

2013-08-18 15:42:51

program new;
{$Define SMART}
{$I SRL/SRL.Simba}
{$i srl/srl/misc/debug.simba}
{$I SRL/SRL/MISC/SMARTGRAPHICS.SIMBA}

procedure FindBanker;
var
TPA: Array of TPoint;
ATPA: T2DPointArray;
Box: TBox;
TheCTS, I, X, Y, H : Integer;

begin
theCTS := GetToleranceSpeed;

SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.04, 0.40);

FindColorsSpiralTolerance(301,175,TPA,11192042, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 40, 40);

SetColorToleranceSpeed(theCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);

H := High(ATPA);
If Length(ATPA) = 0 Then
WriteLn('Length = O, Exiting FindBanker');
Exit;
For I := 0 To H Do
begin
WriteLn('FindBanker ATPA Length = ' + IntToStr (Length(ATPA)));
//SortATPASize(ATPA,True);
SortTPAFrom(TPA, Point(301,175));
MiddleTPAEx(ATPA[I], X, Y);
MMouse(x,y,4,2);
Clickmouse2(mouse_right);
if WaitOption('ank ',500) then
begin
WriteLn('We have found the Banker!');
Wait(1000+random(500));
break;
end;
end;
debugatpabounds(atpa);
end;

begin
setupSRL
begin
FindBanker;
writeln('yay');
end;
end.

Debug:
Paired with SMART[20388]
Failed to RSReady
Failed to RSReady
yay
Successfully executed.

Why will it not find the object or even say the length? I have debug for all outcomes and its not doing anything? Surely I am doing something wrong and I cannot see it. On another script it seems to work. Any help appreciated.

GREEN GIANT

2013-08-18 15:50:58

I'm more than likely wrong as i'm new to scripting, but is it the lack of semi-colon after SetupSRL?

I also noticed that;

SortTPAFrom(TPA, Point(301,175));
MiddleTPAEx(ATPA, X, Y)

You're sorting a TPA and not an ATPA before sending MiddleTPAEX?

Hoodz

2013-08-18 15:57:47

setupsrl();

but maybe you need to add something more. like
begin (stuff here) end ELSE (if not something found)
begin
writeln('not found')
sleep(500)
end

so you know if its not found

The Killer

2013-08-18 15:59:31

TK spotted it!
If Length(ATPA) = 0 Then
WriteLn('Length = O, Exiting FindBanker');
Exit;

missing begin end

Wu-Tang Clan

2013-08-18 16:07:25

From: GREEN GIANT
I'm more than likely wrong as i'm new to scripting, but is it the lack of semi-colon after SetupSRL?

I also noticed that;

SortTPAFrom(TPA, Point(301,175));
MiddleTPAEx(ATPA, X, Y)

You're sorting a TPA and not an ATPA before sending MiddleTPAEX?

You were right, always good to have another pair of eyes :) And I hadn't noticed that I'd left that bit in there. I had ended up going with sortatpasize though. Thanks a lot! Rep 4 u
From: hoodz
setupsrl();

but maybe you need to add something more. like
begin (stuff here) end ELSE (if not something found)
begin
writeln('not found')
sleep(500)
end;

so you know if its not found


Well I do have similar things for that, let me show you:

If Length(ATPA) = 0 Then
WriteLn('Length = O, Exiting FindBanker');
Exit;
If there are no points found in the tpa it will debug that message.

For I := 0 To H Do
begin
WriteLn('FindBanker ATPA Length = ' + IntToStr (Length(ATPA)));
if it didn't display the earlier message, then it should be displaying this message (Which will write out the length of the atpa)


if WaitOption('ank ',500) then
begin
WriteLn('We have found the Banker!');
Wait(1000+random(500));
break;
end;
If the text for the option I'm trying to find is found, then it says that it has been found, or else it would time out of the loop after cycling through the points without finding desired text, or it would have left after TPA length was 0.

Your idea is still very good. I myself love debugging my script to know exactly where it went wrong so I can fine tune it.

Happy scripting guys and thanks for the help.

EDIT: @The Killer, I saw your post after posting this. I ended up seeing that shortly after posting this, but the setupsrl had eluded me.

Ashaman88

2013-08-18 16:09:22

The Killer gave you the answer, you are exiting regardless