Results 1 to 8 of 8

Thread: Why the hell are these 2 procedures repeating?

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Why the hell are these 2 procedures repeating?

    In my script, the procedures walkbank and use bank repeat for some reason and its making me mad.

    Heres what the script does:
    withdraws raw fish
    uses them on range
    chooses cook all
    waits for all the raw fish to disapear.
    walks to the bank(clicking the bank minimap icon)
    opens the bank
    hits store all
    clicks the minimap icon
    opens the bank
    clicks the minimap icon
    opens the bank
    clicks the minimap icon
    opens the bank

    so on and so on until i stop it..

    Heres the script:
    Simba Code:
    program Cook;
    {$i srl/srl.simba}
    const
    rawfishcol=5927257;
    cookrange=7633898;
    cookfish=12868;
    minimap=2216175;
    bank=1857394;
    bankx=305;
    banky=61;
    bankxtwo=404;
    bankytwo=131;
    var
      cookall,usebank,cookicon: Integer;
    procedure backpack;
    var
      X, Y: Integer;
      begin
      if FindColorTolerance(X,Y,4578368,350,296,381,320,5) then
      begin
      MouseSpeed:=15;
      mmouse(x, y,1,1);
      Wait(250 + Random(150));
      ClickMouse(X, Y, mouse_Left);
      Wait(1200 + Random(900));
      end;
    end;
    procedure bankfish;
    var
      X, Y: Integer;
      begin
      Writeln('Looking for bank . . .')
      if FindColorTolerance(X,Y,bank,bankx,banky,bankxtwo,bankytwo,5) then
      begin
      MouseSpeed:=15;
      mmouse(x, y,1,1);
      Writeln('Found bank.')
      Wait(250 + Random(150));
      ClickMouse(x, y, mouse_Right);
      Wait(900 + Random(250));
      FindBitmapToleranceIn(usebank, X, Y,31, 93, 455, 304, 165)
      MouseSpeed:=40;
      mmouse(x, y,1,1);
      WriteLn('Opened Bank!');
      Wait(500 + Random(120));
      ClickMouse(X, Y, mouse_Left);
      Wait(1500 + Random(250));
      backpack;
      end;
    end;
    procedure walkbank;
    var
      X, Y: Integer;
      begin
      if FindColorTolerance(X,Y,minimap,555,85,630,122,5) then
      begin
      mmouse(x, y,1,1);
      Wait(600 + Random(150));
      ClickMouse(x, y, mouse_Left);
      Wait(6500 + Random(1500));
      bankfish;
      end;
    end;
    procedure checkcook;
    var
      X, Y: Integer;
      begin
      if FindColorTolerance(X,Y,rawfishcol,566,217,715,454,5) then
      begin
      Wait(600 + Random(150));
      checkcook;
      end;
      walkbank;
    end;
    procedure choosefish;
    var
      X, Y: Integer;
      begin
      if FindColorTolerance(X,Y,cookfish,207,379,300,452,5) then
      begin
       MouseSpeed:=17;
       mmouse(x, y,1,1);
       Wait(600 + Random(150));
       ClickMouse(x, y, mouse_Right);
       Wait(800 + Random(150));
       FindBitmapToleranceIn(cookall, X, Y,194, 351, 311, 478, 155)
       mmouse(x, y,1,1);
       Wait(600 + Random(150));
       ClickMouse(x, y, mouse_Left);
       checkcook;
      end;
     end;
    procedure cookfisha;
    var
      X, Y: Integer;
         begin
         if FindColorTolerance(X,Y,cookrange,374,12,503,121,5) then
         begin
         if FindColorTolerance(X,Y,rawfishcol,558,218,718,455,5) then
         begin
         MouseSpeed:=17;
         mmouse(x, y,1,1);
         Wait(600 + Random(150));
         ClickMouse(x, y, mouse_Left);
         Wait(600 + Random(150));
         if FindColorTolerance(X,Y,cookrange,374,12,503,121,5) then
         begin
         mmouse(x, y,1,1);
         Wait(600 + Random(150));
         ClickMouse(x, y, mouse_Left);
         Wait(7800 + Random(150));
         choosefish;
        end;
       end;
      end;
     end;
    procedure closecook;
    var
      X, Y: Integer;
      begin
      if FindColorTolerance(X,Y,8421504,423,29,491,45,15) then
      begin
      Wait(800 + Random(150));
      Writeln('Closing bank . . .')
      MouseSpeed:=20;
      mmouse(x, y,1,1);
      Wait(250 + Random(150));
      ClickMouse(x, y, mouse_Left);
      Wait(700 + Random(150));
      cookfisha;
      end;
    end;
    procedure withdrawfish;
    var
      X, Y: Integer;
      begin
      if FindColorTolerance(X,Y,rawfishcol,261,124,389,235,5) then
      begin
      MouseSpeed:=15;
      mmouse(x, y,1,1);
      Wait(350 + Random(150));
      ClickMouse(x, y, mouse_Right);
      MouseSpeed:=10;
      Wait(750 + Random(150));
      mmouse(x, y+65,1,1);
      ClickMouse(x, y, mouse_Left);
      closecook;
      end;
    end;
    begin
    cookall := BitmapFromString(21, 15, 'meJyTUdeWGVA0dccxICJSGaZKiC' +
            'ADAwNBvUA1mCYQ1A5XAFGDZgLx2vFzcQUC3NfICE07mgtxOR5uC6Z' +
            '2rHqJdDye6KOK3wlqx5WE8GsHImRfYw0BNEFcoURnBAAo+e/w');
    usebank := BitmapFromString(38, 13, 'meJyTUdeWoTuauuMYEOHiko3+/2' +
            'dARpg2MjAwYOVSaCMEoFlKaxvR2IPQRggXjtBCBk+ko8UjBBC0Ec5' +
            'GBmjiuCwlOx7xeBDNdirGI6Zf0IIaOcSIsVEGKQ8iG4JmAv7QJinl' +
            '4HI2fr/gSlHEpBy00ENzNlZBglJEKqAPAgANRYUm');
    cookicon := BitmapFromString(9, 11, 'meJw7cICaQPDfP2HrFAiSjV4DJOH' +
            'iTH/+MDIwICNeJWseRT+gOBBBFAMRUASIIFJANQx372JKLQADoCxW' +
            'KYiNaFIQLXB3LkACRHoNAJkkmKw=');
     repeat
          withdrawfish;
          until False;
      FreeBitmap(cookall);
      FreeBitmap(usebank);
      FreeBitmap(cookicon);
    end.

  2. #2
    Join Date
    Nov 2012
    Location
    N/A
    Posts
    185
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    you have at the bottom:

    Simba Code:
    Repeat
      withdrawfish
    Until(False);


    So it is going to keep withdrawing from the bank over and over forever!.

    Change it to something like:
    Simba Code:
    Repeat
      withdrawfish
    Until(InvFull) Or Not(InvEmpty);

    This way its going to keep repeating Withdrawall until your inventory is either full or your inventory is not empty. This way if your down to the last set of fish it will withdraw fro example the last 7 fish and cook them whereas without it, its going to stop before cooking all the fish.

    I could be wrong i have only been learning simba for a week and a bit.

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by tasmania View Post
    you have at the bottom:

    Simba Code:
    Repeat
      withdrawfish
    Until(False);


    So it is going to keep withdrawing from the bank over and over forever!.

    Change it to something like:
    Simba Code:
    Repeat
      withdrawfish
    Until(InvFull) Or Not(InvEmpty);

    This way its going to keep repeating Withdrawall until your inventory is either full or your inventory is not empty. This way if your down to the last set of fish it will withdraw fro example the last 7 fish and cook them whereas without it, its going to stop before cooking all the fish.

    I could be wrong i have only been learning simba for a week and a bit.
    If you read the script your would know that "withdrawfish" is a procedure, and if you read the thread you would know it's not constantly withdrawing fish.

  4. #4
    Join Date
    Nov 2012
    Location
    N/A
    Posts
    185
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    Well if you know everything then why even post with an issue im only trying to help and as i said i am new....

  5. #5
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    First thing I do when debugging scripts is to look through all my code; whenever I have problems following my own code I try to reorganize it so that I can follow it better.
    I see that your procedures all call another procedure, why not try to put the procedures into the mainloop instead?

    so instead of going
    Simba Code:
    Repeat
      withdrawfish
    Until(False);

    try this instead;
    Simba Code:
    Repeat
      withdrawfish
      closecook;
      cookfisha;
      /// ... and so on
    Until(False);

    A thumb rule of procedures is that they execute one step each so that you can call that procedure whenever you want to execute that step soely, and not all the other procedures (like as if the player started at the cooking range instead of in the bank then it would have to cook the food first and then walk to the bank -> repeat)

    You'll get there quickly, just keep on trying It's not an easy task to master scripting, but absolutely worth it

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    First thing I do when debugging scripts is to look through all my code; whenever I have problems following my own code I try to reorganize it so that I can follow it better.
    I see that your procedures all call another procedure, why not try to put the procedures into the mainloop instead?

    so instead of going
    Simba Code:
    Repeat
      withdrawfish
    Until(False);

    try this instead;
    Simba Code:
    Repeat
      withdrawfish
      closecook;
      cookfisha;
      /// ... and so on
    Until(False);

    A thumb rule of procedures is that they execute one step each so that you can call that procedure whenever you want to execute that step soely, and not all the other procedures (like as if the player started at the cooking range instead of in the bank then it would have to cook the food first and then walk to the bank -> repeat)

    You'll get there quickly, just keep on trying It's not an easy task to master scripting, but absolutely worth it


    I'll see how that works out

    EDIT:
    Simba Code:
    repeat
          withdrawfish;
          closecook;
          cookfisha;
          choosefish;
          checkcook;
          walkbank;
          bankfish;
          backpack;
          until (IsKeyDown (114));
      FreeBitmap(cookall);
      FreeBitmap(usebank);
     // FreeBitmap(cookicon);
    end.
    It still kept looping the procedures
    Code:
    walkbank;
    bankfish;
    backpack;
    Last edited by rj; 12-02-2012 at 12:32 AM.

  7. #7
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Try finding out exactly where it is repeating by putting in small WriteLn's everywhere in order to figure out exactly what is going on. i.e try putting some right before and after a FindColorTolerance call; WriteLn('backpack'); in the start of the backpack procedure and WriteLn('backpack; FindColorTolerance: foundcolor'); after the "if findcolortolerance() then begin" part of the procedure

  8. #8
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Try finding out exactly where it is repeating by putting in small WriteLn's everywhere in order to figure out exactly what is going on. i.e try putting some right before and after a FindColorTolerance call; WriteLn('backpack'); in the start of the backpack procedure and WriteLn('backpack; FindColorTolerance: foundcolor'); after the "if findcolortolerance() then begin" part of the procedure
    It's repeating the minimap procedure.
    Last edited by rj; 12-02-2012 at 12:54 AM.

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
  •