SRL Archive - OSR Help

Infinite Loop possibly?


King

2013-03-29 17:50:30

Im making a script to mine and bank clay at Ardounge (Was running fine till I made a change to speed it up)

I want the script to walk to the bank, then bank the clay. If it starts in the bank, it banks fine, if it has to go to the walking procedure, it gets stuck.

So Ive narrowed it down to the procedure that causes issues

Procedure GetIntoBank;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L: Integer;
P: TPoint;

begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.00);
if FindColorsSpiralTolerance(X, Y, TPA, 8618893 , MMX1, MMY1, MMX2, MMY2, 3) then
begin
ATPA := TPAtoATPAEx(TPA, 10, 10);
SortATPAFromFirstPoint(ATPA, Point(690, 93));
//DebugATPA(ATPA, '');
L:=High(ATPA)
for i:=0 to L do
if GetArrayLength(ATPA[i]) > 5 then
begin
P := MiddleTPA(ATPA[i]);
Mouse(P.x, P.y, 3, 3, True);
wait(RandomRange(250,300));
FFlag(1);
end;
end;
end;

The script should click one of the lighter colored tiles in the bank, then wait until the flag is gone and exit, and continue to bank, but sometimes it will click more than once, other times it will then just stop at this point.

Main Loop :

begin
Setup;
repeat
while not LoggedIn do
repeat
LogInPlayer;
until(LoggedIn);
if (not InvFull and not AtRocks) then
WalkToRocks;
if (not InvFull and AtRocks) then
MineRocks;
if (InvFull and AtBank) then
DoBanking;
if (InvFull and not AtBank) then
WalkToBank;
until(False);
end.

Walking to Bank Procedure:

function WalkToBank: Boolean;
var
ToBank: TPointArray;
begin
FindNormalRandoms;
ToBank :=[Point(272,156),Point(272,166),Point(272,174),Point(270,187),Point(265,202),Point(261,218),Point(258,230),Point(247,245),Point(239,260),Point(231,276),Point(227,284),Point(222,301),Point(216,307),Point(205,312),Point(194,320),Point(188,331),Point(184,343),Point(188,347)];
if SPS_WalkPath(ToBank) then
begin
FindNormalRandoms;
GetIntoBank;
result := True;
Status := 'At the bank';
Writeln('Status:' + Status);
exit;
end
else
begin
FindNormalRandoms;
Status := 'Did not walk to the bank, shutting down.';
Writeln('Status:' + Status);
result := false;
TerminateScript;
end;
end;

So how do I get it to continue past this? Everything was working until I added GetIntoBank as a procedure, ideas?

tealc

2013-03-29 18:24:21

try adding exit; after fflag(1);
also you don't have a failsafe incase

if GetArrayLength(ATPA[i]) > 5 then
is always false

King

2013-03-29 18:28:31

From: tealc
try adding exit; after fflag(1);
also you don't have a failsafe incase

if GetArrayLength(ATPA[i]) > 5 then
is always false


Ill add those in, see if it does anything, I forgot I made that par a if then

King

2013-03-29 20:03:16

Doesnt change anything/:

Sin

2013-03-29 20:06:19

Use writelns' EVERYWHERE. Get down to exactly where it gets stuck.

King

2013-03-29 20:07:34

From: Sin
Use writelns' EVERYWHERE. Get down to exactly where it gets stuck.



It gets stuck right after the GetIntoBank procedure I just wanted to post where I use it :P

E* It never exits to the next procedure after GetIntoBank, which should be Banking in the mainloop.

Sin

2013-03-29 20:09:57

Can you tell me which line it stops at? Post the code, and bold the line.

Le Jingle

2013-03-29 20:11:52

I would revise your ACA picked CTS 2 colors, seeing as you have no hue or sat modifiers (only 0.00 x2).

Best bet for a banker would be the suite / clothing they wear (Granted exceptions for custom bank spots).

To help see what's going on, I'd suggest including this:

{$include_once srl/srl/misc/debug.simba}

So you can find the colors, get the TPA, debug the TPA with DebugTPA(TPA, '');.
This will show you what points are retrieved from the TPA searched.

Then after you pick up a good amount of the colors with the TPA finding, I'd Split the TPA into an ATPA as you have, but again (like with the TPA) calling DebugATPA(ATPA, ''); and stopping again, looking at what parts are split up from the TPA, making the ATPA.

Then! Then you can say something like, "well I notice the Banker ATPA has a big blob (aka an index containing a TPA), the biggest on the Screen!" If this is indeed the case, trying something like SortATPASize(ATPA, True); the ATPA will be sorted from Biggest TPA to smallest TPA (note the TPA's make up the ATPA). Then when you loop through the ATPA, you will most likely hit the best TPA right off the start! :]

Cheers,
Le Jingle

King

2013-03-29 20:13:08

From: Sin
Can you tell me which line it stops at? Post the code, and bold the line.



Procedure GetIntoBank;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L: Integer;
P: TPoint;

begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.00);
if FindColorsSpiralTolerance(X, Y, TPA, 8618893 , MMX1, MMY1, MMX2, MMY2, 3) then
begin
ATPA := TPAtoATPAEx(TPA, 10, 10);
SortATPAFromFirstPoint(ATPA, Point(690, 93));
//DebugATPA(ATPA, '');
L:=High(ATPA)
for i:=0 to L do
if GetArrayLength(ATPA[i]) > 5 then
begin
P := MiddleTPA(ATPA[i]);
Mouse(P.x, P.y, 3, 3, True);
[B]wait(RandomRange(250,300)); // It stops after this, it gets all the way through the procedure, but sometimes
FFlag(1);[/B] // it will click another spot twice, like it repeats
end; // Most of the time, it will complete this, open the main inventory then sit with the cursor on the main
end; // inventory button.
end;

King

2013-03-29 20:14:52

From: Le Jingle
I would revise your ACA picked CTS 2 colors, seeing as you have no hue or sat modifiers (only 0.00 x2).

Best bet for a banker would be the suite / clothing they wear (Granted exceptions for custom bank spots).

To help see what's going on, I'd suggest including this:

{$include_once srl/srl/misc/debug.simba}

So you can find the colors, get the TPA, debug the TPA with DebugTPA(TPA, '');.
This will show you what points are retrieved from the TPA searched.

Then after you pick up a good amount of the colors with the TPA finding, I'd Split the TPA into an ATPA as you have, but again (like with the TPA) calling DebugATPA(ATPA, ''); and stopping again, looking at what parts are split up from the TPA, making the ATPA.

Then! Then you can say something like, "well I notice the Banker ATPA has a big blob (aka an index containing a TPA), the biggest on the Screen!" If this is indeed the case, trying something like SortATPASize(ATPA, True); the ATPA will be sorted from Biggest TPA to smallest TPA (note the TPA's make up the ATPA). Then when you loop through the ATPA, you will most likely hit the best TPA right off the start! :]

Cheers,
Le Jingle



The 0.00 colors are for the MM, its the grey bank tile in the bank (Lighter colored one, ACA gives no hue/sat mods) I have a slight tolerance on it, but it never actually misses the color on the MM

Sin

2013-03-29 20:15:56

As far as I can tell, it's either your for loop (to value might be messing it up) or FFlag(); is screwing up.
Try experimenting with FFlag values.

riwu

2013-03-29 20:18:26

You used a loop here:

for i:=0 to L do
which is why it sometimes repeat and click on another spot. So Exit/Break after FFlag().

Is the MM flag still on screen when the script gets stuck?
Also try adding a writeln() after FFlag() and see if that's executed.

King

2013-03-29 20:23:18

From: riwu
You used a loop here:

for i:=0 to L do
which is why it sometimes repeat and click on another spot. So Exit/Break after FFlag().



Is the MM flag still on screen when the script gets stuck?
Also try adding a writeln() after FFlag() and see if that's executed.


It does it with and without FFlag (I tried jsut using a while ismoving do wait(randomrange(25,50));) but that did stop my looping! Ill check the FFlag!

I'd be more than willing to Pm any members the fullscript plus SPS maps if that would help!

King

2013-03-29 20:55:15

I used writeln's it gets through the get into bank procedure, but never starts banking, just sits there @Sin

Total

2013-03-29 21:08:37

Did you try adding Exit; after FFlag(1)?

Olly

2013-03-29 21:21:22

If you click in a non walkable zone on rs the flag will stay there forever, so i guess your doing that?

King

2013-03-29 21:26:58

From: Ollybest
If you click in a non walkable zone on rs the flag will stay there forever, so i guess your doing that?


I fixed it, FindNormal randoms was making it wait for like 4525454545 seconds, @Justin Please close, fixed! Thanks guys!