SRL Archive - Jr. Member General Help and Discussion

Trouble with bankScreen.isOpen


Incurable

2014-10-24 13:57:57

Hi,

Working on my competition script (else I'd post the whole thing) and for some reason bankScreen.isOpen is failing. I've commented where I think the issue is, but I don't think that what I've tried to do has had any success. The script will do 20+ trips back and forth, and randomly fail eventually. I've debugged with screenshots and the bank is always open when it fails.

function useBank(): boolean;
var
waitTimer: TTimeMarker;
begin
writeLn('DEBUG: useBank()');
if (not isLoggedIn()) then exit();
waitTimer.start();

while (waitTimer.getTime() < randomRange(20000, 30000) and (not result)) do
begin
bankScreen.open(BANK_CHEST_LUMBRIDGE);
minimap.waitPlayerMoving(); // I think that the script isn't waiting long enough while moving
wait(gaussRangeInt(1200, 1500)); // which is why I added this line here... different times (2-3kms+), same issue
result := bankScreen.isOpen(gaussRangeInt(8000, 12000)); // Added waitTime here just to see wtf would happen, no idea
// if I shouldn't do it or not
if (result) then
begin
writeLn('DEBUG: useBank result = true, clicking preset');
wait(gaussRangeInt(150, 350));
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(gaussRangeInt(150, 350));
end;
end;
end;


Here's the appropriate debug, I stopped the script manually at that point. Note that the bankScreen is open the entire time this happens.


DEBUG: useBank()
-- TRSBankscreen.__openChest()
---- isMouseOverText()
------ Current mouse-over text: "Use Bank chest"
------ Found "Use Bank" in mouse-over string: "Use Bank chest"
---- isMouseOverText(): True
---- Succesfully opened the bank
-- TRSBankscreen.__openChest() result = true
---- Waiting while the player is moving...
-- TRSBankscreen.__openChest()
---- ERROR: Failed to find enough chest colors [1 4, 2 10 ]
-- TRSBankscreen.__openChest(): result = false
---- Waiting while the player is moving...

As far as I can tell the script clicks on the bank to open it, returns true, waits while the player is moving, then looks for the bank again, but can't find it because the bankScreen is open. Why is it not successfully checking that it's open every time? Bah!

Sorry if I repeated myself, I'm very tired. :p

Thanks.

EDIT: The exact same thing occurrs with this simplified function:


function useBank(): boolean;
begin
if (not isLoggedIn()) then exit();
bankScreen.open(BANK_CHEST_LUMBRIDGE);
minimap.waitPlayerMoving();
result := bankScreen.isOpen(gaussRangeInt(8000, 12000));
if (result) then
begin
wait(gaussRangeInt(150, 350));
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(gaussRangeInt(150, 350));
end;
end;

Kyle

2014-10-24 14:02:51

From: Incurable
….


I don't have SRL 6 on this computer, but I'm assuming the function waits until you stop moving anyway, so that check isn't needed, also when you call result := blah, that is calling it to open the bank chest again, hence why it fails.

Try this:

function useBank(): boolean;
var
waitTimer: TTimeMarker;
begin
writeLn('DEBUG: useBank()');
if (not isLoggedIn()) then exit();
waitTimer.start();

while (waitTimer.getTime() < randomRange(20000, 30000) and (not result)) do
begin
result := bankScreen.open(BANK_CHEST_LUMBRIDGE);
if (result) then
begin
writeLn('DEBUG: useBank result = true, clicking preset');
wait(gaussRangeInt(150, 350));
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(gaussRangeInt(150, 350));
end;
end;
end;

Again, not sure since I can't go and check the function, but I assume it's correct.

Incurable

2014-10-24 14:21:17

From: elfyyy
I don't have SRL 6 on this computer, but I'm assuming the function waits until you stop moving anyway, so that check isn't needed, also when you call result := blah, that is calling it to open the bank chest again, hence why it fails.

Try this:

function useBank(): boolean;
var
waitTimer: TTimeMarker;
begin
writeLn('DEBUG: useBank()');
if (not isLoggedIn()) then exit();
waitTimer.start();

while (waitTimer.getTime() < randomRange(20000, 30000) and (not result)) do
begin
result := bankScreen.open(BANK_CHEST_LUMBRIDGE);
if (result) then
begin
writeLn('DEBUG: useBank result = true, clicking preset');
wait(gaussRangeInt(150, 350));
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(gaussRangeInt(150, 350));
end;
end;
end;

Again, not sure since I can't go and check the function, but I assume it's correct.


That seems to have worked… thanks. :D

EDIT: Scratch that…


DEBUG: useBank()
-- TRSBankscreen.__openChest()
---- isMouseOverText()
------ Current mouse-over text: ""
------ Current mouse-over text: "Use Bank chest"
------ Found "Use Bank" in mouse-over string: "Use Bank chest"
---- isMouseOverText(): True
---- Succesfully opened the bank
-- TRSBankscreen.__openChest() result = true
DEBUG: useBank result = true, clicking preset
-- ERROR: bankScreen.clickButton(): Unable to click button since bankscreen isn't open

The Mayor

2014-10-24 14:47:07

Could try:


function useBank(): boolean;
var
waitTimer: TTimeMarker;
begin
waitTimer.start();

while (waitTimer.getTime() < 30000) and isLoggedIn() do
if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
exit(bankScreen.clickButton(BANK_BUTTON_PRESET_1));
end;

3Garrett3

2014-10-24 14:53:44

From: The Mayor
Could try:


function useBank(): boolean;
var
waitTimer: TTimeMarker;
begin
waitTimer.start();

while (waitTimer.getTime() < 30000) and isLoggedIn() do
if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
exit(bankScreen.clickButton(BANK_BUTTON_PRESET_1));
end;


The problem with this method is the edit Inc put above your post. It opens the bank (returns true on OpenBank) and then when he calls to click the preset button, it says "Unable to click button since bankscreen isn't open".

When I'm home I can try if nobody does before this, but why don't we just run a loop that returns the result of bankScreen.isOpen() like 100 times, waiting 1s (or some other arbitrary but non-negligible number) between checks. If it doesn't come back with 100% success rate then the function should be improved, because this is a key part in a lot of scripts. If it does come back 100% successful then something weird is going on with Inc's script and he should try changing around how he opens the bank.

Camel

2014-10-24 14:54:09

I figure this might help a bit. It's from the bankscreen include, the bankscreen.openChest()


if (isMouseOverText(['Open Shantay chest', 'Open S', 'pen Shant', 'n Shantay','Bank Bank', 'ank Banker', 'ank Bank', 'Use Bank', 'Bank chest'])) then
begin
if (random(3) = 1) then
begin
fastClick(MOUSE_RIGHT);

if (not chooseOption.select(['Open Shantay chest', 'Open S', 'pen Shant', 'n Shantay','Bank Bank', 'ank Banker', 'ank Bank', 'Use Bank', 'Bank chest'])) then
continue;
end else
fastClick(MOUSE_LEFT);

wait(50 + random(100));

if (minimap.isFlagPresent()) then // <= Waits for the flag
minimap.waitFlag(randomRange(12, 15));

result := _waitBankOrPinScreen(randomRange(6000, 8000)); <= waits for it to open

if (result) then
begin
print('Succesfully opened the bank');
break();
end;
end;

The include already waits for the bankscreen and flag.

Kyle

2014-10-24 14:59:50

From: Camel

The include already waits for the bankscreen and flag.


Yup, that's what I figured, about the other stuff, not sure but someone should definitely test it out…

3Garrett3

2014-10-24 15:15:55

From: elfyyy
Yup, that's what I figured, about the other stuff, not sure but someone should definitely test it out…


The problem is that in theory it should work, because openChest shouldn't return true without the bankscreen being there. However, the preset button couldn't be used because it returned that the bankscreen wasn't open. So I don't know how openChest returns true and then using the preset doesn't work, but that's what happened.

Either something very strange is in Inc's code or SRL bankscreen function is not 100% accurate and needs an update.

The Mayor

2014-10-24 16:49:28

From: 3Garrett3
The problem with this method is the edit Inc put above your post. It opens the bank (returns true on OpenBank) and then when he calls to click the preset button, it says "Unable to click button since bankscreen isn't open".

When I'm home I can try if nobody does before this, but why don't we just run a loop that returns the result of bankScreen.isOpen() like 100 times, waiting 1s (or some other arbitrary but non-negligible number) between checks. If it doesn't come back with 100% success rate then the function should be improved, because this is a key part in a lot of scripts. If it does come back 100% successful then something weird is going on with Inc's script and he should try changing around how he opens the bank.


I looped it 100 times without fail before I posted it ;) If isOpen fails then something is blocking the top, the bottom, or the first slot of the bankScreen.

3Garrett3

2014-10-24 17:33:39

From: The Mayor
I looped it 100 times without fail before I posted it ;) If isOpen fails then something is blocking the top, the bottom, or the first slot of the bankScreen.


This is very strange then. I wonder how it would come to his debug:

DEBUG: useBank()
-- TRSBankscreen.__openChest()
---- isMouseOverText()
------ Current mouse-over text: ""
------ Current mouse-over text: "Use Bank chest"
------ Found "Use Bank" in mouse-over string: "Use Bank chest"
---- isMouseOverText(): True
---- Succesfully opened the bank
-- TRSBankscreen.__openChest() result = true
DEBUG: useBank result = true, clicking preset
-- ERROR: bankScreen.clickButton(): Unable to click button since bankscreen isn't open

So if bankScreen.isOpen works 100% of the time, what could be causing this in both the code he posted, and Elfyyy's solution? I was helping him debug and had no idea what could cause that result.

Ashaman88

2014-10-24 17:38:39

Try resetting interfaces and double checking graphics settings

Incurable

2014-10-24 22:32:35

From: Ashaman88
Try resetting interfaces and double checking graphics settings


I did this and the script ran for 20 minutes before stopping due to a mistake I made… I guess my interfaces were just wrong. o.O

Thanks for all of your help guys, I'll post again if it magically decides to fail, but 20 minutes is the longest it has ran without error.

*sigh*


DEBUG: useBank()
-- TRSBankscreen.__openChest()
---- isMouseOverText()
------ Current mouse-over text: "Use Bank chest"
------ Found "Use Bank" in mouse-over string: "Use Bank chest"
---- isMouseOverText(): True
---- Succesfully opened the bank
-- TRSBankscreen.__openChest() result = true
DEBUG: useBank result = true, clicking preset
-- ERROR: bankScreen.clickButton(): Unable to click button since bankscreen isn't open

Using:


function useBank(): boolean;
var
waitTimer: TTimeMarker;
begin
if (not isLoggedIn()) then exit();
waitTimer.start();

while (waitTimer.getTime() < randomRange(20000, 30000) and (not result)) do
result := bankScreen.open(BANK_CHEST_LUMBRIDGE);
if (result) then
begin
wait(gaussRangeInt(250, 450));
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(gaussRangeInt(350, 450));
end;
end;

Incurable

2014-10-25 02:53:44

Sorry for the double-post, but…

This code:


function useBank(): boolean;
var
waitTimer: TTimeMarker;
begin
if (not isLoggedIn()) then exit();
waitTimer.start();
while (waitTimer.getTime() < randomRange(20000, 30000) and (not result)) do
begin
bankScreen.open(BANK_CHEST_LUMBRIDGE);
wait(gaussRangeInt(250, 450));
result := bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(gaussRangeInt(350, 450));
end;
end;

… failed after:


DEBUG: ProgRep()
*** Inc's Lumby Smelter v0.9 ***
Loads done: 35
Smelted: 315
Profit: 82215
Profit/hr: 150545
Time Running: 32 min 46 sec

… with this debug:


-- TRSBankscreen.__openChest()
---- isMouseOverText()
------ Current mouse-over text: ""
------ Current mouse-over text: "Use Bank chest"
------ Found "Use Bank" in mouse-over string: "Use Bank chest"
---- isMouseOverText(): True
---- Succesfully opened the bank
-- TRSBankscreen.__openChest() result = true
-- ERROR: bankScreen.clickButton(): Unable to click button since bankscreen isn't open

I seriously have no idea why this is happening and I've spent hours trying to fix it. :(

EDIT: Here's the main loop, just in case there's something here that someone notices…


begin
pathLodeToBank := [Point(227, 222), Point(200, 171), Point(179, 136), Point(153, 85)];

smartShowConsole := false; // TODO: DELETE THIS
smartEnableDrawing := true;
SetupSRL();
DeclarePlayers();
SPS.setup('LUM_FUR_MAP', RUNESCAPE_OTHER);
isScriptRunning := true;

while (isScriptRunning) do
begin
if (not isLoggedIn()) then players[currentPlayer].login();
SetupScreen();
lodeTele();

if (walkThePath(pathLodeToBank)) then
repeat
if (not useBank()) then
break();
if (not minimap.setAngle(gaussRangeInt(288, 318))) then
break()
else
wait(gaussRangeInt(400, 600));
if (findFurnace()) then
SmeltOre()
else
break();
if (not minimap.setAngle(gaussRangeInt(18, 38))) then
break()
else
wait(gaussRangeInt(400, 600));
ProgRep();
until (numSmelted >= CFG_NUM_TO_SMELT) or (not isLoggedIn());
if (numSmelted >= CFG_NUM_TO_SMELT) then isScriptRunning := false;
end;

if (isLoggedIn()) then players[currentPlayer].logout();
ProgRep();
end.

EDIT2: Ran for another hour before it failed with the same error… then failed again after 3 minutes in another trip…