SRL Archive - RS3 Help

How to make it not repeat a single procedure


nero_dante

2015-03-05 13:45:07

Hey again, okay I have made some progress with my script however, I do not wish for it to do one of the procedures everytime. And getting a bit confused as to what to type so that it would check if that specific procedure has been done already.

This is the code, but I don't want it to do 'SwitchtoNorthHigh' procedure everytime it finishes a lap. Any help on that.

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'username';
password := 'password';
isActive := true;
isMember := false;
end
currentPlayer := 0;
end;

procedure SwitchtoNorthHigh();
var
resetcamera: Tbox;
begin
resetcamera := intTobox(586, 25, 606, 41);
MouseBox(resetcamera, MOUSE_LEFT);
WriteLn('Starting up Lap');
mainScreen.setAngle(MS_ANGLE_HIGH);
end;

procedure WalkLogBeam();
var
logBeam: Tbox;
begin
LogBeam := intTobox(286, 50, 293, 180);
mouseBox(LogBeam, MOUSE_LEFT);
WriteLn('Walking over LogBeam');
wait(gaussRangeInt(5800,6200));
end;
procedure ClimbUpWall();
var
Wall: Tbox;
begin
Wall := intTobox(277, 76, 305, 99);
mouseBox(Wall, MOUSE_LEFT);
WriteLn('Climbing up wall');
wait(gaussRangeInt(6800,7000));
end;
Procedure WalkAcrossBalancingLedge();
var
Ledge: Tbox;
begin
Ledge := intTobox(156, 146, 181, 150);
mouseBox(Ledge, MOUSE_LEFT);
WriteLn('Walking across Balancing Ledge');
wait(gaussRangeInt(6000,6200));
end;
procedure ClimbOverLowWall();
var
LowWall: Tbox;
begin
LowWall :=intTobox(235, 209, 251, 299);
mouseBox(LowWall, MOUSE_LEFT);
WriteLn('Climbing over Low Wall');
wait(gaussRangeInt(4800,5200));
end;
procedure SwingonRope();
var
SwingRope: Tbox;
begin
SwingRope :=intTobox(351, 167, 371, 191);
mouseBox(SwingRope, MOUSE_LEFT);
WriteLn('Swinging on Rope');
wait(gaussRangeInt(3000,4000));
end;
procedure SwingAcrossMonkeyBars();
var
MonkeyBar: Tbox;
begin
MonkeyBar :=intTobox(292, 241, 351, 251);
mouseBox(MonkeyBar, MOUSE_LEFT);
WriteLn('Swinging across Monkey Bars');
wait(gaussRangeInt(7800,8300));
end;
procedure JumpDownledge();
var
JumpLedge: Tbox;
begin
JumpLedge :=intTobox(230, 200, 278, 209);
mouseBox(JumpLedge, MOUSE_LEFT);
WriteLn('Finishing Lap');
wait(gaussRangeInt(2200,2600));
end;
procedure StartingOver();
var
Starttile: Tbox;
begin
Starttile :=intTobox(372, 189, 390, 207);
mouseBox(Starttile, MOUSE_LEFT);
WriteLn('Starting New Lap');
wait(gaussRangeInt(1900,2500));
end;
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
end;

SwitchtoNorthHigh();
WalkLogBeam();
ClimbUpWall();
WalkAcrossBalancingLedge();
ClimbOverLowWall();
SwingonRope();
SwingacrossMonkeyBars();
JumpDownLedge();
StartingOver();
until(false);
end.

the bank

2015-03-05 13:50:09

Take it out of your loop.

Currently you loop:

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

SwitchtoNorthHigh();
WalkLogBeam();
ClimbUpWall();
WalkAcrossBalancingLedge();
ClimbOverLowWall();
SwingonRope();
SwingacrossMonkeyBars();
JumpDownLedge();
StartingOver();
until(false);

So take SwitchtoNorthHigh() and put it below declarePlayers and out of your loop.

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
SwitchtoNorthHigh();
repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
end;

WalkLogBeam();
ClimbUpWall();
WalkAcrossBalancingLedge();
ClimbOverLowWall();
SwingonRope();
SwingacrossMonkeyBars();
JumpDownLedge();
StartingOver();
until(false);
end.

nero_dante

2015-03-05 13:56:02

yeah I was going to do that, but if for example it logs out and I need it to go back do that procedure again, will it do it? I know the whole script would mess up if it doesn't log out at the start of the course but just for future reference, how would I get the script to know if a specific procedure has already completed.

the bank

2015-03-05 14:13:35

My solution would be to create a procedure called loginPlayer() that will call players[currentPlayer].login(), exitTreasure() etc and at the end call your north/high function and if the player isnt logged in then invoke that procedure.

3Garrett3

2015-03-05 14:27:42

From: nero_dante
yeah I was going to do that, but if for example it logs out and I need it to go back do that procedure again, will it do it? I know the whole script would mess up if it doesn't log out at the start of the course but just for future reference, how would I get the script to know if a specific procedure has already completed.


Could you not do this then:


begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
SwitchtoNorthHigh();
end;

WalkLogBeam();
ClimbUpWall();
WalkAcrossBalancingLedge();
ClimbOverLowWall();
SwingonRope();
SwingacrossMonkeyBars();
JumpDownLedge();
StartingOver();
until(false);
end.

I guess you could also leave it where the bank suggested and then put it in the login portion as well. This way will only work if you start logged out. I typically like to have a setup() function in my script that calls all the initial login and any other stuff you need. You could call that before your loop, and then call the compass setup in your 6 hour fix code.

the bank

2015-03-05 14:47:15

Here is your script with the feature I just described implemented. I also formatted your code and commented my changes.

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'username';
password := 'password';
isActive := true;
isMember := false;
end
currentPlayer := 0;
end;

procedure SwitchtoNorthHigh();
var
resetcamera: Tbox;
begin
resetcamera := intTobox(586, 25, 606, 41);
MouseBox(resetcamera, MOUSE_LEFT);
WriteLn('Starting up Lap');
mainScreen.setAngle(MS_ANGLE_HIGH);
end;

procedure WalkLogBeam();
var
logBeam: Tbox;
begin
LogBeam := intTobox(286, 50, 293, 180);
mouseBox(LogBeam, MOUSE_LEFT);
WriteLn('Walking over LogBeam');
wait(gaussRangeInt(5800, 6200));
end;

procedure ClimbUpWall();
var
Wall: Tbox;
begin
Wall := intTobox(277, 76, 305, 99);
mouseBox(Wall, MOUSE_LEFT);
WriteLn('Climbing up wall');
wait(gaussRangeInt(6800, 7000));
end;

procedure WalkAcrossBalancingLedge();
var
Ledge: Tbox;
begin
Ledge := intTobox(156, 146, 181, 150);
mouseBox(Ledge, MOUSE_LEFT);
WriteLn('Walking across Balancing Ledge');
wait(gaussRangeInt(6000, 6200));
end;

procedure ClimbOverLowWall();
var
LowWall: Tbox;
begin
LowWall := intTobox(235, 209, 251, 299);
mouseBox(LowWall, MOUSE_LEFT);
WriteLn('Climbing over Low Wall');
wait(gaussRangeInt(4800, 5200));
end;

procedure SwingonRope();
var
SwingRope: Tbox;
begin
SwingRope := intTobox(351, 167, 371, 191);
mouseBox(SwingRope, MOUSE_LEFT);
WriteLn('Swinging on Rope');
wait(gaussRangeInt(3000, 4000));
end;

procedure SwingAcrossMonkeyBars();
var
MonkeyBar: Tbox;
begin
MonkeyBar := intTobox(292, 241, 351, 251);
mouseBox(MonkeyBar, MOUSE_LEFT);
WriteLn('Swinging across Monkey Bars');
wait(gaussRangeInt(7800, 8300));
end;

procedure JumpDownledge();
var
JumpLedge: Tbox;
begin
JumpLedge := intTobox(230, 200, 278, 209);
mouseBox(JumpLedge, MOUSE_LEFT);
WriteLn('Finishing Lap');
wait(gaussRangeInt(2200, 2600));
end;

procedure StartingOver();
var
Starttile: Tbox;
begin
Starttile := intTobox(372, 189, 390, 207);
mouseBox(Starttile, MOUSE_LEFT);
WriteLn('Starting New Lap');
wait(gaussRangeInt(1900, 2500));
end;

procedure loginPlayer();
begin
players[currentPlayer].login(); //Same as your original check
exitTreasure();
SwitchtoNorthHigh(); //Logged in again, fix the compass!
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
SwitchtoNorthHigh(); //Call it outside of the loop so it will execute at the beginning
repeat
if not isLoggedIn() then
begin
loginPlayer(); //Custom relogin procedure that takes care of all the steup
end;
WalkLogBeam();
ClimbUpWall();
WalkAcrossBalancingLedge();
ClimbOverLowWall();
SwingonRope();
SwingacrossMonkeyBars();
JumpDownLedge();
StartingOver();
until (false);
end.

nero_dante

2015-03-05 16:37:13

From: the bank
Here is your script with the feature I just described implemented. I also formatted your code and commented my changes.

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'username';
password := 'password';
isActive := true;
isMember := false;
end
currentPlayer := 0;
end;

procedure SwitchtoNorthHigh();
var
resetcamera: Tbox;
begin
resetcamera := intTobox(586, 25, 606, 41);
MouseBox(resetcamera, MOUSE_LEFT);
WriteLn('Starting up Lap');
mainScreen.setAngle(MS_ANGLE_HIGH);
end;

procedure WalkLogBeam();
var
logBeam: Tbox;
begin
LogBeam := intTobox(286, 50, 293, 180);
mouseBox(LogBeam, MOUSE_LEFT);
WriteLn('Walking over LogBeam');
wait(gaussRangeInt(5800, 6200));
end;

procedure ClimbUpWall();
var
Wall: Tbox;
begin
Wall := intTobox(277, 76, 305, 99);
mouseBox(Wall, MOUSE_LEFT);
WriteLn('Climbing up wall');
wait(gaussRangeInt(6800, 7000));
end;

procedure WalkAcrossBalancingLedge();
var
Ledge: Tbox;
begin
Ledge := intTobox(156, 146, 181, 150);
mouseBox(Ledge, MOUSE_LEFT);
WriteLn('Walking across Balancing Ledge');
wait(gaussRangeInt(6000, 6200));
end;

procedure ClimbOverLowWall();
var
LowWall: Tbox;
begin
LowWall := intTobox(235, 209, 251, 299);
mouseBox(LowWall, MOUSE_LEFT);
WriteLn('Climbing over Low Wall');
wait(gaussRangeInt(4800, 5200));
end;

procedure SwingonRope();
var
SwingRope: Tbox;
begin
SwingRope := intTobox(351, 167, 371, 191);
mouseBox(SwingRope, MOUSE_LEFT);
WriteLn('Swinging on Rope');
wait(gaussRangeInt(3000, 4000));
end;

procedure SwingAcrossMonkeyBars();
var
MonkeyBar: Tbox;
begin
MonkeyBar := intTobox(292, 241, 351, 251);
mouseBox(MonkeyBar, MOUSE_LEFT);
WriteLn('Swinging across Monkey Bars');
wait(gaussRangeInt(7800, 8300));
end;

procedure JumpDownledge();
var
JumpLedge: Tbox;
begin
JumpLedge := intTobox(230, 200, 278, 209);
mouseBox(JumpLedge, MOUSE_LEFT);
WriteLn('Finishing Lap');
wait(gaussRangeInt(2200, 2600));
end;

procedure StartingOver();
var
Starttile: Tbox;
begin
Starttile := intTobox(372, 189, 390, 207);
mouseBox(Starttile, MOUSE_LEFT);
WriteLn('Starting New Lap');
wait(gaussRangeInt(1900, 2500));
end;

procedure loginPlayer();
begin
players[currentPlayer].login(); //Same as your original check
exitTreasure();
SwitchtoNorthHigh(); //Logged in again, fix the compass!
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
SwitchtoNorthHigh(); //Call it outside of the loop so it will execute at the beginning
repeat
if not isLoggedIn() then
begin
loginPlayer(); //Custom relogin procedure that takes care of all the steup
end;
WalkLogBeam();
ClimbUpWall();
WalkAcrossBalancingLedge();
ClimbOverLowWall();
SwingonRope();
SwingacrossMonkeyBars();
JumpDownLedge();
StartingOver();
until (false);
end.


Thanks :) .. Simba won't create a client right now for some reason so I'll check that out tomrrow :) Thanks for help.

Also thanks aswell Garrett :)