SRL Archive - Jr. Member General Help and Discussion

ATPA help


Thomas

2015-04-09 05:19:19

Hey,

Why is my function adding wrong TPA's to my array?
Image should contain code and example.
I'm unsure what's wrong.

riwu

2015-04-09 05:22:55

too high tolerance?
use the ACA aid by nielsie

KeepBotting

2015-04-09 05:25:54

Please post code in plain text, using Simba tags :) super hard to read it off an image

It looks like your code works just fine – judging from the screenshot, you've successfully found and clicked your desired object. What's not working as expected?

If you mean the other crap off to the right of the screen, you could try filtering your TPAs by size to get rid of them

E: or possibly those are left over from other runs of the script? You seem to have many TPAs labeled with the same index, perhaps you never cleared the smartImage and are mistaking them?

Thomas

2015-04-09 05:31:25

I suppose I should filter by size, how do I do that? I'll also lower some tolerances.
They aren't left over pretty sure.

Citrus

2015-04-09 05:33:21

From: lovebotter
I suppose I should filter by size, how do I do that? I'll also lower some tolerances.
They aren't left over pretty sure.


http://docs.villavu.com/srl-6/tpointarrays.html#t2dpointarray-sortbysize

Also, are you using ACA to get your colors?

KeepBotting

2015-04-09 05:37:08

From: lovebotter
I suppose I should filter by size, how do I do that? I'll also lower some tolerances.
They aren't left over pretty sure.


atpa.sortBySize(); //sorts largest-first
atpa.sortBySize(false); //sorts smallest-first
atpa.filterBetween(0, 25) //removes ATPAs that have lengths in between 0 and 25

There's several ways.

Thomas

2015-04-09 05:37:29

From: evilcitrus
http://docs.villavu.com/srl-6/tpointarrays.html#t2dpointarray-sortbysize

Also, are you using ACA to get your colors?


Yes I am! Currently it was sorting from closest.
But how do I make sure it doesn't even add the small TPA's to the array?

Great keepbotting! Will try that!

Thomas

2015-04-09 05:38:42

Another problem:
function banking(preset: integer): boolean;
var
button: integer;
backpackResult: boolean;
begin
if not isLoggedIn then
exit;
timer.start;
if preset = 1 then
begin
backpackResult := tabBackpack.isEmpty;
button := BANK_BUTTON_PRESET_1;
end;
if preset = 2 then
begin
backpackResult := tabBackpack.isItemInSlot(1);
button := BANK_BUTTON_PRESET_2;
end;
begin
repeat
if bankscreen.open(14) then
break
else
setCamera;
if (timer.getTime > timeOut) or (not isLoggedIn) then
exit;
until (bankScreen.isOpen or pinscreen.isOpen);
pinScreen.Enter(players[currentPlayer].bankPin);
repeat
wait(gaussRangeInt(100, 500));
if bankScreen.clickButton(button) then
break;
if (timer.getTime > timeOut) or (not isLoggedIn) then
exit;
until (not bankScreen.isOpen);
end;
repeat
wait(gaussRangeInt(100, 500));
if (backpackResult) then
begin
writeln('backpackResult true');
break;
end;
if (timer.getTime > timeOut) then
begin
writeln('Failed withdrawing, shutting down');
players[currentPlayer].logout;
terminateScript;
end;
if not isLoggedIn then
exit;
until (false);
if (backpackResult) then
result := true;
end;

The backpackResult boolean doesn't seem to work? It never returns true so the script times out.

KeepBotting

2015-04-09 05:41:43

From: lovebotter
Another problem:
function banking(preset: integer): boolean;
var
button: integer;
backpackResult: boolean;
begin
if not isLoggedIn then
exit;
timer.start;
if preset = 1 then
begin
backpackResult := tabBackpack.isEmpty;
button := BANK_BUTTON_PRESET_1;
end;
if preset = 2 then
begin
backpackResult := tabBackpack.isItemInSlot(1);
button := BANK_BUTTON_PRESET_2;
end;
begin
repeat
if bankscreen.open(14) then
break
else
setCamera;
if (timer.getTime > timeOut) or (not isLoggedIn) then
exit;
until (bankScreen.isOpen or pinscreen.isOpen);
pinScreen.Enter(players[currentPlayer].bankPin);
repeat
wait(gaussRangeInt(100, 500));
if bankScreen.clickButton(button) then
break;
if (timer.getTime > timeOut) or (not isLoggedIn) then
exit;
until (not bankScreen.isOpen);
end;
repeat
wait(gaussRangeInt(100, 500));
if (backpackResult) then
begin
writeln('backpackResult true');
break;
end;
if (timer.getTime > timeOut) then
begin
writeln('Failed withdrawing, shutting down');
players[currentPlayer].logout;
terminateScript;
end;
if not isLoggedIn then
exit;
until (false);
if (backpackResult) then
result := true;
end;

The backpackResult boolean doesn't seem to work? It never returns true so the script times out.


writeLn it out whenever you set it, i.e.


{ . . . }

if preset = 1 then
begin
backpackResult := tabBackpack.isEmpty;
button := BANK_BUTTON_PRESET_1;
writeLn('backpackResult returns ' + lowercase(toStr(backpackResult)));
end;

{ . . . }

if preset = 2 then
begin
backpackResult := tabBackpack.isItemInSlot(1);
button := BANK_BUTTON_PRESET_2;
writeLn('backpackResult returns ' + lowercase(toStr(backpackResult)))
end;


This way, you can see exactly what is returning which values, and when

Thomas

2015-04-09 05:51:29

From: KeepBotting
writeLn it out whenever you set it, i.e.


{ . . . }

if preset = 1 then
begin
backpackResult := tabBackpack.isEmpty;
button := BANK_BUTTON_PRESET_1;
writeLn('backpackResult returns ' + lowercase(toStr(backpackResult)));
end;

{ . . . }

if preset = 2 then
begin
backpackResult := tabBackpack.isItemInSlot(1);
button := BANK_BUTTON_PRESET_2;
writeLn('backpackResult returns ' + lowercase(toStr(backpackResult)))
end;


This way, you can see exactly what is returning which values, and when


If I add it like that, it would only tell me when I'm using preset 1 and when I'm using preset 2, and it does that correctly. I just want to have the backpackResult be the boolean to determine if my entire banking function has been done correctly, and that it waits after clicking the preset untill the backpackResult is true.

(Btw I just tried adding those lines and it does return false/true, but still it timesout whenever it waits for backpackResult to be true near end)

Thomas

2015-04-09 06:03:39

  writeLn('backpackResult returns ' + lowercase(toStr(backpackResult)));
if (backpackResult) then
result := true;
end;
Always returns false. So something is wrong, wouldn't know what though.

Thomas

2015-04-09 06:34:31

I have filtered the wrong TPA's, how do I randomly click in a TPA? Instead of the center?
for i := 0 to high(portATPA) do
begin
mouse(middleTPA(portATPA[i]), MOUSE_MOVE);
if isMouseOverText(['well', 'ortab'], 2500) then
begin
result := true;
break;
end
else
result := false;
end;

Can't seem to find it in the TPA includes?

Citrus

2015-04-09 07:13:25

I would try tbox.getGaussPoint, using tpa.getBounds as the tbox
and maybe shrink it a bit first

Thomas

2015-04-09 08:05:30

I used middletpaex and then mouse (x,y, rand, rand, move) for now.
Will try the gaussian, as I prefer those.

Still torn on the banking though!

Citrus

2015-04-09 08:15:15

From: lovebotter
Still torn on the banking though!


It looks like you're trying to look in tabBackPack while the bank is open? I don't think you can do that.

Thomas

2015-04-09 08:30:11

From: evilcitrus
It looks like you're trying to look in tabBackPack while the bank is open? I don't think you can do that.



It doesnt start checking bankpackresultn untill waiting for (not bankscreen.isopen) is finished.

Citrus

2015-04-09 08:58:48

From: lovebotter
It doesnt start checking bankpackresultn untill waiting for (not bankscreen.isopen) is finished.


Ohhh I see. I've never used bankScreen.open before so I though it said isOpen

Thomas

2015-04-09 09:11:12

Another thing; the portable wells get removed after 5 minutes, how can I clear the ATPA? Because once I let the script put up a new well it draws another TPA on it.

KeepBotting

2015-04-09 09:14:51

From: lovebotter
Another thing; the portable wells get removed after 5 minutes, how can I clear the ATPA? Because once I let the script put up a new well it draws another TPA on it.


You could set your ATPA variable to an empty array

someAtpa := [];

Thomas

2015-04-09 10:58:47

From: KeepBotting
You could set your ATPA variable to an empty array

someAtpa := [];


Thanks! Finished all the stuff needed. I just implemented the result checks in my mainloop. Those were needed to make it logout when out of supplies.

Will post the script in juniors later after next test run.