Results 1 to 8 of 8

Thread: Procedure help

  1. #1
    Join Date
    Mar 2013
    Posts
    94
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default Procedure help

    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:

    Simba Code:
    Program Random;

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

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

    Thanks in advance

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    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:
    Simba Code:
    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

  3. #3
    Join Date
    Mar 2013
    Posts
    94
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    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:
    Simba Code:
    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.

    Simba Code:
    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;
    Last edited by rsbots2013; 05-28-2013 at 06:22 AM.

  4. #4
    Join Date
    Sep 2012
    Location
    Australia.
    Posts
    839
    Mentioned
    16 Post(s)
    Quoted
    225 Post(s)

    Default

    Just add where you want to add it:

    Simba Code:
    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;

  5. #5
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Also, instead of writing:

    Simba Code:
    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:
    Simba Code:
    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;

  6. #6
    Join Date
    Mar 2013
    Posts
    94
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Chris! View Post
    Just add where you want to add it:

    Simba Code:
    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!

  7. #7
    Join Date
    Mar 2013
    Posts
    94
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Also, instead of writing:

    Simba Code:
    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:
    Simba Code:
    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

  8. #8
    Join Date
    Mar 2008
    Posts
    426
    Mentioned
    1 Post(s)
    Quoted
    116 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Also, instead of writing:
    ...
    ..
    .
    Use else
    ..
    ..
    Thanks! My script looks neater and its easier to read when you use else.

    REP +

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •