SRL Archive - OSR Help

1st script help - cant get script to loop/repeat


digitalninja

2012-08-28 01:49:51

Hi Folks,

I am almost done with my 1st script. I have spent countless hours watching tutorials and reading up on common errors. I cant seem to figure this out. I have gotten the script to open SIMBA, login, bank, deposit, close, and then run the code below. After its done I expected it to loop back to bank but it instead just logs out. I think I have screwed up a failsafe which is triggering the early logout. Can someone see what I did wrong and how I can just get it to loop again please?


procedure Rind;
var
FailSafe : Integer;
begin
FailSafe := 0;
InvMouse(1, 1);
ClickMouse2(True);
Wait(RandomRange(800, 900));
MMouse((MCX1+MCX2)/2 ,(MCY1+MCY2)/2 , 5, 5);
while not(IsUpText('All')) do
begin
Wait(RandomRange(20, 40));
Inc(FailSafe);
if (FailSafe > 50) then
begin
Writeln('Couldn''t find the make all button!');
FindNormalRandoms;
Inc(SuperFailSafe);
if (SuperFailSafe > 2) then
Rind;
Exit;
end;
end;
Writeln(inttostr(failsafe));
ClickMouse2(True);
repeat
wait(100);
Inc(x);
until(x > WaitTimer);
AntiBan;
x :=0;
FindNormalRandoms;
SuperFailSafe := 0;
end;

I get the feeling the error is happening on the last part

  
Writeln(inttostr(failsafe));
ClickMouse2(True);
repeat
wait(100);
Inc(x);
until(x > WaitTimer);
AntiBan;
x :=0;
FindNormalRandoms;
SuperFailSafe := 0;
end;

But all I see here is a delay and random finder :confused:

Thanks!

Digital Ninja

riwu

2012-08-28 03:18:11

You have to show the whole script (esp. the mainloop) for us to find out the problem.
procedure Rind;
var
FailSafe : Integer;
begin
FailSafe := 0;
InvMouse(1, 1);
ClickMouse2(True);
Wait(RandomRange(800, 900));
MMouse((MCX1+MCX2)/2 ,(MCY1+MCY2)/2 , 5, 5);
while not(IsUpText('All')) do //can just use WaitUpText instead (pre-made loop of IsUpText)
begin
Wait(RandomRange(20, 40));
Inc(FailSafe);
if (FailSafe > 50) then
begin
Writeln('Couldn''t find the make all button!');
FindNormalRandoms;
Inc(SuperFailSafe);
if (SuperFailSafe > 2) then
Rind;
//so if Superfailsafe<3 it's going to exit this procedure, i think u intended the other way round?
Exit;
end;
end;
Writeln(inttostr(failsafe));
ClickMouse2(True);
repeat
wait(100);
Inc(x);
until(x > WaitTimer); //what's this WaitTimer?
AntiBan;
x :=0;
FindNormalRandoms;
SuperFailSafe := 0;
end;

Oxygen

2012-08-28 09:16:22

Do you have a mainloop?
And does it look like

repeat
Bank;
Withdraw;
Close;
Rind;
until (false); // thats an infinity loop but you can have something else there too.

digitalninja

2012-08-28 09:37:34

Ok ok … fine … I will show you the full code I just didnt want to show everyone cause then they would steal my 1st script ever and who wouldnt want a script to grind mud runes :spot:


//by Digital Ninja
//This script is simply meant to grind mud runes for making extreme
//magic potions. Its rather boring so I thought a script would be perfect!
//This is my 1st script attempt and complete credit goes to Griff and
//YoHoJo for their tutorials as well as Getdropped whos Herbalore script //helped me understand banking and invmouse functions and provided the //backbone for this script!

program Grind;
{$DEFINE SMART}
{$I SRL/SRL.Simba}


var
x, SuperFailSafe : Integer;

const
BankOption = 1; // 0 for bankers and 1 for soulwars chest!
WaitTimer = 150;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := ''; //Character Name
Pass := ''; //Character Pass
Pin := ''; //Pin for bank
Active := true;
end;
end;


procedure AntiBan;
begin
case Random(500) of
0..2:
HoverSkill('Herblore', false);
3:
GameTab(26);
12..15:
PickUpMouse;
16..20:
RandomMovement;
26..27:
RandomRClick;
28..30:
BoredHuman;
33:
ExamineInv;
34:
RandomAngle(SRL_ANGLE_HIGH);
35..40:
GameTab(25);

end;
SetAngle(SRL_ANGLE_HIGH);
Wait(RandomRange(100, 200));
end;

function Bank: Boolean;
begin
If BankOption = 1 then
begin
repeat
SetAngle(SRL_ANGLE_HIGH);
OpenBankChest(SRL_BANK_SW);
until BankScreen or PinScreen;
end;

If BankOption = 0 then
begin
repeat
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
OpenBankNPC;
until BankScreen or PinScreen or not(LoggedIn);
end;

if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until BankScreen or not(LoggedIn);
end;

if BankScreen then
begin
Wait(RandomRange(200, 300));
InvMouse(2, mouse_Right);
WaitOption('All', 2000);
CloseBank;
Wait(RandomRange(500, 600));
end;

end;


procedure Rind;
var
FailSafe : Integer;
begin
FailSafe := 0;
InvMouse(1, 1);
ClickMouse2(True);
Wait(RandomRange(800, 900));
MMouse((MCX1+MCX2)/2 ,(MCY1+MCY2)/2 , 5, 5);
while not(IsUpText('All')) do
begin
Wait(RandomRange(20, 40));
Inc(FailSafe);
if (FailSafe > 50) then
begin
Writeln('Couldn''t find the make all button!');
FindNormalRandoms;
Inc(SuperFailSafe);
if (SuperFailSafe > 2) then
Rind;
Exit;
end;
end;
Writeln(inttostr(failsafe));
ClickMouse2(True);
repeat
wait(100);
Inc(x);
until(x > WaitTimer);
AntiBan;
x :=0;
FindNormalRandoms;
SuperFailSafe := 0;
end;

begin
Cleardebug;
{$IFDEF SMART}
{$IFDEF SIMBAMAJOR980}
Smart_Server := 40;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ELSE}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
{$ENDIF}
SetupSRL;
DeclarePlayers;
LoginPlayer;
Writeln('Welcome to Digital Ninjas Mud Rune Grind!');
Wait(800);
SetAngle(SRL_ANGLE_HIGH);

repeat //main loop
Bank;
Rind;
until
Logout;
end.

You can see at the end I have the mainloop set up to bank and rind (in this script I dont really need to withdraw anything since runes stack).

Probably not the most cutting edge of a script but I have 2500+ extreme magic potions to make and I realized while grinding runes manually this would be something a script could do for me :).

Footy

2012-08-28 09:42:50

Your until in the main loop should look like
Until(not(logged in));
What you wrote will do a loop, then log out.
E: you don't need all that compatibility stuff in your main loop either, as previous versions of simba simply won't work, they are incompatible.

Oxygen

2012-08-28 12:03:22

* Ninja'd

digitalninja

2012-08-28 20:57:24

Thanks Footy … I added your until fix and now the script doesnt compile -


[Hint] C:\Simba\Includes\SRL/SRL/core/antirandoms\randomtool.simba(215:3): Variable 'T' never used at line 214
[Hint] C:\Simba\Scripts\MudRuneGrinder.simba(64:10): Variable 'Result' never used at line 63
[Error] C:\Simba\Scripts\MudRuneGrinder.simba(160:13): Unknown identifier 'log' at line 159
Compiling failed.

Any idea why it wouldnt recognize the log function?

Footy

2012-08-28 21:06:42

I need to see the updated script to answer that. Is log a function? Are you trying to call the function before its actually made(Calling log above where you made the function)?

P1ng

2012-08-28 21:08:56

Line 159 is almost the last line of the script. Did you perhaps change Logout to Log? In which case it will have no idea what you mean.

Footy

2012-08-28 21:15:51

^ Bang, thats it. You must have written until(not(log)); or something along those lines. Make sure its until(not(loggedin));

digitalninja

2012-08-28 22:09:31

Thanks footy … the difference was there was a space in the 1st one and not in the 2nd and it worked! My 1st script is complete thanks to everyone help!! WOOHOO!! Works like MAGIC! Man that was hard … =P

Footy

2012-08-28 22:14:48

Glad I could help! And don't worry, it gets easier the more you practice!