SRL Archive - RS3 Help

Code not repeating as intended?


trips

2015-05-22 22:58:57

Hello,

I am trying to make something that keeps moving my camera around until it finds a certain object. However I can't get it to do so.

This is what I have ATM.

begin

repeat
minimap.setAngle(Random(360));
wait(randomRange(2000, 3000 ));
until findColorsSpiralTolerance(x, y, TPA, 3033169, mainScreen.getBounds(), 6, colorSetting(2, 0.11, 0.97));


if length(TPA) < 1 then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['up Ladder'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;

Incurable

2015-05-22 23:13:16

Which part do you want to repeat? Because at present it's going to run through it until it finds the colours, then go through the rest.

trips

2015-05-22 23:15:59

From: Incurable
Which part do you want to repeat? Because at present it's going to run through it until it finds the colours, then go through the rest.


I want it to keep moving the camerag around until it has found the object.. It's not always found. So I need the camera to keep moving UNTIL the object is found. The current code I have atm doesn't do anything. It doesn't keep spinning the camerea. I tested it.

It moved it once and still didn't find it then just sat there.

Clutch

2015-05-22 23:37:11

From: trips
I want it to keep moving the camerag around until it has found the object.. It's not always found. So I need the camera to keep moving UNTIL the object is found. The current code I have atm doesn't do anything. It doesn't keep spinning the camerea. I tested it.

It moved it once and still didn't find it then just sat there.

Have you double checked your colors on the object?

adc

2015-05-22 23:44:00

From: trips
I want it to keep moving the camerag around until it has found the object.. It's not always found. So I need the camera to keep moving UNTIL the object is found. The current code I have atm doesn't do anything. It doesn't keep spinning the camerea. I tested it.

It moved it once and still didn't find it then just sat there.


Presumably, then, it's turning and finding the color you specified and then stopping the loop. The color doesn't necessarily have to be on the object you're looking for.

Incurable

2015-05-22 23:46:43

From: trips
I want it to keep moving the camerag around until it has found the object.. It's not always found. So I need the camera to keep moving UNTIL the object is found. The current code I have atm doesn't do anything. It doesn't keep spinning the camerea. I tested it.

It moved it once and still didn't find it then just sat there.


I tested the following code (basically yours) and it worked for me:


program Script;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure OpenBank();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
repeat
minimap.setAngle(Random(360));
wait(randomRange(2000, 3000 ));
until findColorsSpiralTolerance(x, y, TPA, 7445943, mainScreen.getBounds(), 6, colorSetting(2, 0.12, 1.63));

if length(TPA) < 1 then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['ank'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;
end;

begin
smartEnableDrawing := true;
SetupSRL();
OpenBank();
end.

Can you show me a screenshot of your debugged ATPA like this (the one's I just got testing your code):


fady

2015-05-22 23:47:12

From: trips
I want it to keep moving the camerag around until it has found the object.. It's not always found. So I need the camera to keep moving UNTIL the object is found. The current code I have atm doesn't do anything. It doesn't keep spinning the camerea. I tested it.

It moved it once and still didn't find it then just sat there.


1st of all are you sure that the color is unique to what you are looking for?
2nd Does the debug not show anything?
3rd can you try debugging just the TPA and see where the points it found were?

King

2015-05-23 01:57:46

Do what the others above have mentioned, but set a timer / countdown for a failure to find the item as to avoid an infinite loop, also adding debugging so you know where the script is not working.

begin



repeat
FailCount = 0;
minimap.setAngle(Random(360));
wait(randomRange(2000, 3000 ));
inc(FailCount);
until findColorsSpiralTolerance(x, y, TPA, 3033169, mainScreen.getBounds(), 6, colorSetting(2, 0.11, 0.97) or (FailCount > 10));

if (FailCount > 10) then
writln("We failed to find the specified object ten or more times..");


if length(TPA) < 1 then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['up Ladder'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;

Not tested as I am on a Mac and not running parallels..Also add FailCount as a global integer so you can use it elsewhere too.

trips

2015-05-23 03:45:39

From: King
Do what the others above have mentioned, but set a timer / countdown for a failure to find the item as to avoid an infinite loop, also adding debugging so you know where the script is not working.

begin




repeat
FailCount = 0;
minimap.setAngle(Random(360));
wait(randomRange(2000, 3000 ));
inc(FailCount);
until findColorsSpiralTolerance(x, y, TPA, 3033169, mainScreen.getBounds(), 6, colorSetting(2, 0.11, 0.97) or (FailCount > 10));

if (FailCount > 10) then
writln("We failed to find the specified object ten or more times..");


if length(TPA) < 1 then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['up Ladder'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;

Not tested as I am on a Mac and not running parallels..Also add FailCount as a global integer so you can use it elsewhere too.


Thanks for that, I appreciate it. I'll use it. I have made progress since then, that is why I have replied slow.

Appreciate everyone's response. I ended up using SPS to get the respawn room made my character walk to the ladder if it was not found. It hasn't been tested much but I think it's going to do the trick.

King

2015-05-23 10:41:56

From: trips
Thanks for that, I appreciate it. I'll use it. I have made progress since then, that is why I have replied slow.

Appreciate everyone's response. I ended up using SPS to get the respawn room made my character walk to the ladder if it was not found. It hasn't been tested much but I think it's going to do the trick.


Glad to hear that you have made progress! Feel free to post if any other issues arise!