SRL Archive - Jr. Member General Help and Discussion

Script not logging in problem...


Incurable

2014-09-28 04:28:57

So I recently realised that when my script is logged out for whatever reason, it won't actually log in. I changed this:

 
repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3)));

… to this:

 
repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3) or (not isLoggedIn()));

… with advice from slacky and Dgby714.

However, the script terminates when it reaches my Terminate procedure, as commented below:


// Main loop to be performed while the script is active
procedure MainLoop();
begin
// If not logged in, log in
if (not isLoggedIn()) then
begin
players[currentPlayer].login();
writeLn('SUCCESS: Logged in');
end;

if (isLoggedIn() and tabBackpack.isEmpty()) then
begin
SetupScreen();
writeLn('STATUS: Walking to bank to do banking');
WalkToBank();
end;

repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3) or (not isLoggedIn()));

if (numFilled >= CFG_NUM_TO_FILL) then
begin
writeLn('SUCCESS: Filled desired vials, remember to post a proggy! :D');
isScriptRunning := false;
end else
if (failCount < 3) then // This is reached and printed in debug despite failCount being 0 when testing
writeLn('ERROR: Errr... the number of vials filled appears to be less than you wanted filled. Please post a proggy + debug on the forum.');

if (failCount = 3) then // This is reached too
writeLn('FATAL ERROR: Script failCount = 3, terminating script.');
Terminate('failCount >= 3');
end;

{ ============================================================================ }

// Main procedure
begin
SetupEverything();
while(isScriptRunning) do
MainLoop();
EndScript();
end.

I'm testing the script by letting it get to FillVials, and while they're filling, pausing the script and logging out. I had hoped that this would just break out of the repeat..until and then go back to the start of MainLoop, but it's not. Instead it's terminating the whole script which makes me unsure of whether or not it will do the same if it's logged out via lag/etc.

Any ideas?

EDIT: It just did it after 4 hours and 23 minutes, so the script definitely does not log back in once logged out via lag. :(

Lucidity

2014-09-28 13:48:19

repeat
if (not isLoggedIn()) then
begin
players[currentPlayer].login();
writeLn('SUCCESS: Logged in');
end;
until isLoggedIn();

You could remove that from Main loop, and put that before MainLoop(); and the script might stop running, due is "isScriptRunning" it won't go to MainLoop where you have the sign in, bc the script isn't running. (If i'm mistaken, please correct me)

Try


// Main loop to be performed while the script is active
procedure MainLoop();
begin

if (isLoggedIn() and tabBackpack.isEmpty()) then
begin
SetupScreen();
writeLn('STATUS: Walking to bank to do banking');
WalkToBank();
end;

repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3) or (not isLoggedIn()));

if (numFilled >= CFG_NUM_TO_FILL) then
begin
writeLn('SUCCESS: Filled desired vials, remember to post a proggy! :D');
isScriptRunning := false;
end else
if (failCount < 3) then // This is reached and printed in debug despite failCount being 0 when testing
writeLn('ERROR: Errr... the number of vials filled appears to be less than you wanted filled. Please post a proggy + debug on the forum.');

if (failCount = 3) then // This is reached too
writeLn('FATAL ERROR: Script failCount = 3, terminating script.');
Terminate('failCount >= 3');
end;

{ ============================================================================ }

// Main procedure
begin
SetupEverything();
repeat
if (not isLoggedIn()) then
begin
players[currentPlayer].login();
writeLn('SUCCESS: Logged in');
end;
until isLoggedIn();
repeat
MainLoop();
until False;

EndScript();
end.

vvarfare

2014-09-28 15:44:36

if not isLoggedIn() then
begin
players[currentPlayer].login();

That should be included before you repeat

The Mayor

2014-09-28 16:49:21


repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3)));



repeat
if not isLoggedIn() then
players[CurrentPlayer].login();

UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3)));

Incurable

2014-09-28 21:19:26

From: The Mayor

repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3)));



repeat
if not isLoggedIn() then
players[CurrentPlayer].login();

UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3)));


Does this not have the same affect?:


repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3) or (not isLoggedIn()));

I had what you've suggested yesterday and had the same problem.

EDIT: Huh… it worked. I don't understand why, so if you could explain it I would appreciate it, but thank you regardless.

bonsai

2014-09-28 21:34:29

From: Incurable
Does this not have the same affect?:


repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3) or (not isLoggedIn()));

I had what you've suggested yesterday and had the same problem.


I didn't run a lape test but it's not safe to assume a language will execute all of the statements in a test like that.

Most languages are smart about processing 'or' statements. If either side is true the whole statement is true.

So if it does the first test, and it's true, why bother doing the second one?

So don't count on the second or third item to run.

The Mayor

2014-09-28 21:46:16

From: Incurable
Does this not have the same affect?:


repeat
UseBank();
WalkToFountain();
FillVials();
WalkToBank();
ProgRep();
until ((numFilled >= CFG_NUM_TO_FILL) or (failCount >= 3) or (not isLoggedIn()));

I had what you've suggested yesterday and had the same problem.

EDIT: Huh… it worked. I don't understand why, so if you could explain it I would appreciate it, but thank you regardless.


By adding not isLoggedIn() to the until condition, it will just break out of that loop if your player isn't logged in (if you don't have any infinite loops in the rest of those procedures). Since you tell your player to log back in at the top if your main loop, it should have the same effect.

However, if you do it this way, your script will actually terminate when it breaks out of the loop, because:


if (failCount = 3) then // This is reached too
writeLn('FATAL ERROR: Script failCount = 3, terminating script.');
Terminate('failCount >= 3');

Incurable

2014-09-28 22:07:01

From: bonsai
I didn't run a lape test but it's not safe to assume a language will execute all of the statements in a test like that.

Most languages are smart about processing 'or' statements. If either side is true the whole statement is true.

So if it does the first test, and it's true, why bother doing the second one?

So don't count on the second or third item to run.


I wasn't aware of that, thanks. I'll have to keep it mind. But I'm also quite sure that that's fine in this case, isn't it? I want it to stop repeating if any of those conditions are true.

From: The Mayor
By adding not isLoggedIn() to the until condition, it will just break out of that loop if your player isn't logged in (if you don't have any infinite loops in the rest of those procedures). Since you tell your player to log back in at the top if your main loop, it should have the same effect.

However, if you do it this way, your script will actually terminate when it breaks out of the loop, because:


if (failCount = 3) then // This is reached too
writeLn('FATAL ERROR: Script failCount = 3, terminating script.');
Terminate('failCount >= 3');


Oh hang on, is it reaching Terminate because it's not part of that if statement?

EDIT: It was, and I've fixed it… thanks!