SRL Archive - OSR Help

Procedure help


rsbots2013

2013-05-28 00:24:39

From inside a procedure on SRL-OSR, is it possible to tell Simba to go another procedure that's not next in the main loop. for example:


Program Random;

procedure New;
begin
if FindDTM(x) then
RunToWall
end;

begin
RunToHill;
RunToWall;
WalkToBank;
New;
RunToCastle;
WalkToFurnace;
end.

Thanks in advance :)

Le Jingle

2013-05-28 00:58:39

If I understand correctly, you are trying to figure out how to call another procedure via a separate procedure called within the main loop?

in that case, here's an example:

program new;

procedure HelloWorld();
begin
WriteLn('Hello World');
end;

procedure Foo();
begin
// Calls procedure HelloWorld()
HelloWorld();
end;

begin
WriteLn('Start');
Foo();
WriteLn('End');
end.

If not, let me know in more detail and I'll try to help out best I can :)
-Lj

rsbots2013

2013-05-28 02:19:52

From: Le Jingle
If I understand correctly, you are trying to figure out how to call another procedure via a separate procedure called within the main loop?

in that case, here's an example:

program new;

procedure HelloWorld();
begin
WriteLn('Hello World');
end;

procedure Foo();
begin
// Calls procedure HelloWorld()
HelloWorld();
end;

begin
WriteLn('Start');
Foo();
WriteLn('End');
end.

If not, let me know in more detail and I'll try to help out best I can :)
-Lj


Thanks for your reply

When I tried that I got "assignment expected" in the debug box.

Heres my script. How do I Make it go to another procedure. I'm wiritng in a spot where I was it to go, look at my script.

procedure FailedRopeSwing;

var
x, y : integer;

begin
Wait(4000);
if FindColorSpiralTolerance( x, y, SkeletonColor, 6, 5, 513, 336, 5) then
// Looking for Skeleton
begin
//Found Skeleton
WriteLn('Failed Rope Swing... Attempting to leave Dungeon');
WriteLn('Found Skeleton in Dungeon');
MakeCompass('W');
SetAngle(SRL_ANGLE_LOW);
if FindColorSpiralTolerance( x, y, GoUpSkeletonDungeonLadderColor, 210, 145, 338, 230, 5) then
if not FindColorSpiralTolerance( x, y, GoUpSkeletonDungeonLadderColor, 210, 145, 338, 230, 5) then
// Looking for Ladder to escape the dungeon
begin
// Failed to find Ladder
WriteLn('Failed to find Ladder');
Wait(10000);
end;
begin
// Found Ladder
WriteLn('Found ladder color');
MoveMouse( x, y);
if WaitUptextMulti(['Clim', 'limb', 'Lad', 'der'], 600) then
begin
WriteLn('Found Ladder Uptext');
Mouse( x, y, 0, 0, False);
if WaitOptionMulti(['Clim', 'limb', 'b-u'], 600) then
Wait(3000);
////////////I want to go to another procedure right here. ////////////////////
end;
end;
end;
if not FindColorSpiralTolerance( x, y, SkeletonColor, 6, 5, 513, 336, 5) then
// If failed to find Skeleton then we have passed
begin
WriteLn('Successfully passed Rope Swing');
end;
end;

Chris!

2013-05-28 02:26:35

Just add where you want to add it:

if WaitOptionMulti(['Clim', 'limb', 'b-u'], 600) then
begin
Wait(3000);
ProcedureNameYouWantToGoToo; //Make sure the procedure you wish to go to is ABOVE this procedure!
end;

The Mayor

2013-05-28 02:35:01

Also, instead of writing:


if not FindColorSpiralTolerance( x, y, GoUpSkeletonDungeonLadderColor, 210, 145, 338, 230, 5) then

if not FindColorSpiralTolerance( x, y, SkeletonColor, 6, 5, 513, 336, 5) then

You can just use an else statement, like so:


procedure FailedRopeSwing;

var
x, y : integer;

begin
Wait(4000);
if FindColorSpiralTolerance(x, y, SkeletonColor, 6, 5, 513, 336, 5) then
begin
WriteLn('Failed Rope Swing... Attempting to leave Dungeon');
WriteLn('Found Skeleton in Dungeon');
MakeCompass('W');
SetAngle(SRL_ANGLE_LOW);
if FindColorSpiralTolerance(x, y, GoUpSkeletonDungeonLadderColor, 210, 145, 338, 230, 5) then
begin
WriteLn('Found ladder color');
MoveMouse(x, y);
if WaitUptextMulti(['Clim', 'limb', 'Lad', 'der'], 600) then
begin
WriteLn('Found Ladder Uptext');
Mouse( x, y, 0, 0, False);
if WaitOptionMulti(['Clim', 'limb', 'b-u'], 600) then
begin
Wait(3000);
{You can call your procedure here}
end;
end;
end else
begin
WriteLn('Failed to find Ladder');
Wait(10000);
end;
end else
WriteLn('Successfully passed Rope Swing');
end;


rsbots2013

2013-05-28 06:04:37

From: Chris!
Just add where you want to add it:

if WaitOptionMulti(['Clim', 'limb', 'b-u'], 600) then
begin
Wait(3000);
ProcedureNameYouWantToGoToo; //Make sure the procedure you wish to go to is ABOVE this procedure!
end;


IT WORKED!!!!!!!!!!!!!!!!!11111 thank you chris!

rsbots2013

2013-05-28 06:07:22

From: The Mayor
Also, instead of writing:


if not FindColorSpiralTolerance( x, y, GoUpSkeletonDungeonLadderColor, 210, 145, 338, 230, 5) then

if not FindColorSpiralTolerance( x, y, SkeletonColor, 6, 5, 513, 336, 5) then

You can just use an else statement, like so:


procedure FailedRopeSwing;

var
x, y : integer;

begin
Wait(4000);
if FindColorSpiralTolerance(x, y, SkeletonColor, 6, 5, 513, 336, 5) then
begin
WriteLn('Failed Rope Swing... Attempting to leave Dungeon');
WriteLn('Found Skeleton in Dungeon');
MakeCompass('W');
SetAngle(SRL_ANGLE_LOW);
if FindColorSpiralTolerance(x, y, GoUpSkeletonDungeonLadderColor, 210, 145, 338, 230, 5) then
begin
WriteLn('Found ladder color');
MoveMouse(x, y);
if WaitUptextMulti(['Clim', 'limb', 'Lad', 'der'], 600) then
begin
WriteLn('Found Ladder Uptext');
Mouse( x, y, 0, 0, False);
if WaitOptionMulti(['Clim', 'limb', 'b-u'], 600) then
begin
Wait(3000);
{You can call your procedure here}
end;
end;
end else
begin
WriteLn('Failed to find Ladder');
Wait(10000);
end;
end else
WriteLn('Successfully passed Rope Swing');
end;



I will try my best to work with else instead of If not. seems to working good :)

Peanuts

2013-05-28 07:57:49

From: The Mayor
Also, instead of writing:
…
..
.
Use else
..
..



Thanks! My script looks neater and its easier to read when you use else.

REP +