Results 1 to 7 of 7

Thread: Help with standards

  1. #1
    Join Date
    Sep 2013
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    20 Post(s)

    Smile Help with standards

    Hello! I am trying to get my standards correct in my script before I apply for membership.
    I am having a little trouble with this procedure as its quite large and contains many different statements.

    If someone could please look over it and tell me why it is not correct so I can improve.

    Thanks!

    Simba Code:
    procedure BankCustom;
    var
      TPAA: T2DPointArray;
      CTS, L, I, X, Y, Tries, BankFound: Integer;
      TPA: TPointArray;

    begin
        repeat
          PlayerProtection;
          CTS := GetColorToleranceSpeed;
          ColorToleranceSpeed(2);
          SetColorSpeed2Modifiers(0.11, 2.93);
          FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2051676, MSX1, MSY1, MSX2, MSY2, 4);

          TPAA := TPAToATPAEx(TPA, 200, 100);
          DebugATPA(TPAA,'');
          L := High(TPAA);
          ColorToleranceSpeed(CTS);
          for I := 0 to L do
          begin
            MiddleTPAEx(TPAA[i], X, Y);
            MMouse(X, Y, 3, 3);
            if WaitUptext('th', 300) then
            begin
              GetMousePos(X, Y);
              Mouse(X, Y, 0, 0, True);
              Wait(2500 + Random(500));
              BankFound := 1;
              Break;
            end;
          end;

          if not BankScreen then
          begin
            if not WaitUptext('th', 300) then
            begin
              MakeCompass(randomrange(-20, 20));
              blindwalk(Point(3254 + random(1), 3420 + random(1)));
              PlayerProtection;
              inc(Tries)
              WriteLn('Attempt number: ' + IntToStr(Tries));
            end;
         end;

         if Tries > 5 then
         begin
            WriteLn('Failed finding the bank too many times. Exiting Script.');
            Logout;
            TerminateScript;
         end;

      until(BankFound = 1);


       if PinScreen then
       begin
         InPin(BANKPIN);
       end;

      repeat
        if BankScreen then
        begin
          if finddtm(EssDTM, X, Y, MSX1, MSY1, MSX2, MSY2) then
          begin
            QuickDeposit('inv');
            WriteLn('Commencing Banking');
            MMouse(X, Y, 3, 3);
            wait(randomrange(10, 30));
            GetMousePos(X, Y);
            Mouse(X, Y, 0, 0, mouse_right);
            wait(randomrange(10, 30));
            ChooseOption('Withdraw-All')
            wait(randomrange(10, 30));
            CloseBank;
            Writeln('Banking Complete');
            PlayerProtection;
            Exit;
          end else
          begin
            WriteLn('Could not find the Essence DTM. Consider making another one.');
            Logout;
            TerminateScript;
          end;
       end;
     until (False);
    end;
    Last edited by Cage; 10-05-2013 at 05:59 PM.

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Cage View Post
    Hello! I am trying to get my standards correct in my script before I apply for membership.
    I am having a little trouble with this procedure as its quite large and contains many different statements.

    If someone could please look over it and tell me why it is not correct so I can improve. :)

    Thanks!

    Simba Code:
    procedure BankCustom;
    var
      TPAA: T2DPointArray;
      CTS, L, I, X, Y, Tries, BankFound: Integer;
      TPA: TPointArray;

    begin
        repeat
          PlayerProtection;
          CTS := GetColorToleranceSpeed;
          ColorToleranceSpeed(2);
          SetColorSpeed2Modifiers(0.11, 2.93);
          FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2051676, MSX1, MSY1, MSX2, MSY2, 4);

          TPAA := TPAToATPAEx(TPA, 200, 100);
          DebugATPA(TPAA,'');
          L := High(TPAA);
          ColorToleranceSpeed(CTS);
          for I := 0 to L do
          begin
            MiddleTPAEx(TPAA[i], X, Y);
            MMouse(X, Y, 3, 3);
            if WaitUptext('th', 300) then
            begin
              GetMousePos(X, Y);
              Mouse(X, Y, 0, 0, True);
              Wait(2500 + Random(500));
              BankFound := 1;
              Break;
            end;
          end;

          if not BankScreen then
          begin
            if not WaitUptext('th', 300) then
            begin
              MakeCompass(randomrange(-20, 20));
              blindwalk(Point(3254 + random(1), 3420 + random(1)));
              PlayerProtection;
              inc(Tries)
              WriteLn('Attempt number: ' + IntToStr(Tries));
            end;
         end;

         if Tries > 5 then
         begin
            WriteLn('Failed finding the bank too many times. Exiting Script.');
            Logout;
            TerminateScript;
         end;

      until(BankFound = 1);


       if PinScreen then
       begin
         InPin(BANKPIN);
       end;

      repeat
        if BankScreen then
        begin
          if finddtm(EssDTM, X, Y, MSX1, MSY1, MSX2, MSY2) then
          begin
            QuickDeposit('inv');
            WriteLn('Commencing Banking');
            MMouse(X, Y, 3, 3);
            wait(randomrange(10, 30));
            GetMousePos(X, Y);
            Mouse(X, Y, 0, 0, mouse_right);
            wait(randomrange(10, 30));
            ChooseOption('Withdraw-All')
            wait(randomrange(10, 30));
            CloseBank;
            Writeln('Banking Complete');
            PlayerProtection;
            Exit;
          end else
          begin
            WriteLn('Could not find the Essence DTM. Consider making another one.');
            Logout;
            TerminateScript;
          end;
       end;
     until (False);
    end;
    Don't leave a white line after your var declaration, otherwise the method looks fragmented.
    Your first repeat (along with some of the codes below it) has 2 white tabs, just need 1.
    Other than that it's okay, but i advise you not to have any potential infinite loop ;)

  3. #3
    Join Date
    Sep 2013
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    20 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Don't leave a white line after your var declaration, otherwise the method looks fragmented.
    Your first repeat (along with some of the codes below it) has 2 white tabs, just need 1.
    Other than that it's okay, but i advise you not to have any potential infinite loop
    Thanks for the info.

  4. #4
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by Cage View Post
    Hello! I am trying to get my standards correct in my script before I apply for membership.
    I am having a little trouble with this procedure as its quite large and contains many different statements.

    If someone could please look over it and tell me why it is not correct so I can improve.

    Thanks!

    Simba Code:
    procedure BankCustom;
    var
      TPAA: T2DPointArray;
      CTS, L, I, X, Y, Tries, BankFound: Integer;
      TPA: TPointArray;

    begin
        repeat
          PlayerProtection;
          CTS := GetColorToleranceSpeed;
          ColorToleranceSpeed(2);
          SetColorSpeed2Modifiers(0.11, 2.93);
          FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2051676, MSX1, MSY1, MSX2, MSY2, 4);

          TPAA := TPAToATPAEx(TPA, 200, 100);
          DebugATPA(TPAA,'');
          L := High(TPAA);
          ColorToleranceSpeed(CTS);
          for I := 0 to L do
          begin
            MiddleTPAEx(TPAA[i], X, Y);
            MMouse(X, Y, 3, 3);
            if WaitUptext('th', 300) then
            begin
              GetMousePos(X, Y);
              Mouse(X, Y, 0, 0, True);
              Wait(2500 + Random(500));
              BankFound := 1;
              Break;
            end;
          end;

          if not BankScreen then
          begin
            if not WaitUptext('th', 300) then
            begin
              MakeCompass(randomrange(-20, 20));
              blindwalk(Point(3254 + random(1), 3420 + random(1)));
              PlayerProtection;
              inc(Tries)
              WriteLn('Attempt number: ' + IntToStr(Tries));
            end;
         end;

         if Tries > 5 then
         begin
            WriteLn('Failed finding the bank too many times. Exiting Script.');
            Logout;
            TerminateScript;
         end;

      until(BankFound = 1);


       if PinScreen then
       begin
         InPin(BANKPIN);
       end;

      repeat
        if BankScreen then
        begin
          if finddtm(EssDTM, X, Y, MSX1, MSY1, MSX2, MSY2) then
          begin
            QuickDeposit('inv');
            WriteLn('Commencing Banking');
            MMouse(X, Y, 3, 3);
            wait(randomrange(10, 30));
            GetMousePos(X, Y);
            Mouse(X, Y, 0, 0, mouse_right);
            wait(randomrange(10, 30));
            ChooseOption('Withdraw-All')
            wait(randomrange(10, 30));
            CloseBank;
            Writeln('Banking Complete');
            PlayerProtection;
            Exit;
          end else
          begin
            WriteLn('Could not find the Essence DTM. Consider making another one.');
            Logout;
            TerminateScript;
          end;
       end;
     until (False);
    end;
    http://www.diffchecker.com/ynff7y0h

    Not sure why diffchecker throws the 'ChooseOption' off but in Simba it's correct.
    Last edited by Justin; 10-06-2013 at 02:55 AM.

    Forum account issues? Please send me a PM

  5. #5
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    standards are good

    Simba Code:
    if PinScreen then
       begin
         InPin(BANKPIN); //only one statement for if..then
       end;

    Can be shortened since there's only one followup action after if.. then
    the begin..end; is redundant.
    if there were multiple followup actions then a begin..end; was necessary

    Simba Code:
    if PinScreen then InPin(BANKPIN); //no need for a new begin/end;

    Creds to DannyRS for this wonderful sig!

  6. #6
    Join Date
    Jun 2008
    Location
    United States
    Posts
    818
    Mentioned
    60 Post(s)
    Quoted
    90 Post(s)

    Default

    Quote Originally Posted by Sjoe View Post
    Simba Code:
    if PinScreen then InPin(BANKPIN); //no need for a new begin/end;
    While we are at it, it's generally accepted to be poor, standards-wise, to throw the body of an if statement after the then. Should be:

    Simba Code:
    if (PinScreen) then
      InPin();

    Also note the parentheses around the clause of the if statement.
    [10/14/13:19:03] <BenLand100> this is special relatively, just cleverly disguised with yachts

  7. #7
    Join Date
    Sep 2013
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    20 Post(s)

    Default

    Thanks for everybody's input. Ill be sure to implement your suggestions before I submit my application!

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
  •