Results 1 to 7 of 7

Thread: Anyway to make this simpler?

  1. #1
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default Anyway to make this simpler?

    Simba Code:
    Procedure Patch1;  //Walks from loadstone to farming patch in Cath.
    Begin
     If(RadialWalkTolerance(1660230,290,300,70,2,2,10)) Then
     Begin
       Writeln('Walking to patch 1 is fine');
       FFlag(0);
       If(RadialWalkTolerance(1396030,307,325,35,2,2,10)) Then
       Begin
        Writeln('Ready to plant at patch 1');
        Exit;
       End;
     End;
    End;

    Procedure Patch2; //Walks from loadstone to farming patch Fally/Draynor
    Begin
      If(RadialWalkTolerance(2907482,266,251,72,2,2,10)) Then
      Begin
        Writeln('Walking to patch 2 is fine..');
        FFlag(3);
        If(RadialWalkTolerance(2909285,275,265,73,2,2,10)) Then
        Begin
          Writeln('Walking to patch 2 is still okay..');
          FFlag(3);
          If(RadialWalkTolerance(2188651,307,300,74,2,2,10)) Then
          Begin
            FFlag(3);
            Writeln('Walking to patch 2 is still okay, almost there..');
            While(IsMoving) Do
            AntiBan;
            If Not IsMoving Then
            Begin
              Writeln('Ready to plant at patch 2');
            End;
          End;
        End;
      End;
    End;

    I feel like there could be a easier way to do this, or at lest look cleaner.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  2. #2
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quick example using cases and for..to..do:

    Simba Code:
    function WalkTo(Which: String): Boolean;
    var
      PathVars: array of TIntegerArray;
      PathColor: TIntegerArray;
      // Whatever else: TIntegerArray;
      hPathColor, i: Integer;
    begin
      Result := False;
      case Lowercase(Which) of
        'patch1':
        begin
          SetLength(PathVars, 2);
          PathColor := [1660230,1396030];
          PathVars[0] := [290,300,70,2,2,10];
          PathVars[1] := [307,325,35,2,2,10];
        end;
        // 'patch2':
      end;
      hPathColor := High(PathColor);
      for i := 0 to hPathColor do
      begin
        if RadialWalkTolerance(PathColor[i],PathVars[i][0],PathVars[i][1],PathVars[i][2],PathVars[i][3],PathVars[i][4],PathVars[i][5]) then
        begin
          // Writeln('Walking to '+Which+': '+IntToStr(i+1)+' of '+IntToStr(hPathColor+1));
          FFlag(0);
          if (i = hPathColor) then
            Result := True;
          // ...  
        end;
        // ...
      end;
    end;

    Then you can call it like this:

    Simba Code:
    if WalkTo('patch1') then
      // Writeln('Walked to patch 1!');
    Last edited by Runaway; 06-07-2012 at 04:19 AM.

  3. #3
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    I get most of it, but do you mind explaining

    Simba Code:
    if RadialWalkTolerance(PathColor[i],PathVars[i][0],PathVars[i][1],PathVars[i][2],PathVars[i][3],PathVars[i][4],PathVars[i][5]) then
        begin
          // Writeln('Walking to '+Which+': '+IntToStr(i+1)+' of '+IntToStr(hPathColor+1));
          FFlag(0);
          if (i = hPathColor) then
            Result := True;
          // ...
        end;
        // ...
      end;
    end;
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  4. #4
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Sure.

    Since you use RadialWalkTolerance() the whole time but just change the variables, that's what I've done here. You set all of the variables in the case, and then use them all in order with this "generic" statement. If you're confused about the whole PathColor[i] and PathVars[i][0] thing, hopefully this will clear it up:

    Simba Code:
    PathColor[0] := 1660230;

    PathVars[0][0] := 290;
    PathVars[0][1] := 300;
    PathVars[0][2] := 70;
    // etc.

    So when i := 0 in the for..to..do loop, the PathColor and PathVars will be the parameters of the first RadialWalkTolerance() of 'patch1' that you called in the original script. Then when that search is complete (and FFlag(0) is done) it will move onto i := 1 and the next vars will be loaded into RadialWalkTolerance().

    Hopefully I explained it well enough >.<

  5. #5
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Okay, I think I understand...so like this right?


    Simba Code:
    Function WalkTo(Which: String): Boolean;
    Var
      PathVars: array of TIntegerArray;
      PathColor: TIntegerArray;
      hPathColor, i: Integer;
    Begin
      Result := False;
      Case Lowercase(Which) Of
        'patch1':
        Begin
          SetLength(PathVars, 2);
          PathColor := [1660230,1396030];
          PathVars[0] := [290,300,70,2,2,10];
          PathVars[1] := [307,325,35,2,2,10];
        End;
        'patch2':
        Begin
          SetLength(PathVars, 3);
          PathColor := [2907482,2909285,2188651];
          PathVars[0] := [266,251,72,2,2,10];
          PathVars[1] := [275,265,73,2,2,10];
          PathVars[2] := [307,300,74,2,2,10];
        End;
      End;
      hPathColor := High(PathColor);
      for i := 0 to hPathColor do
      Begin
        if RadialWalkTolerance(PathColor[i],PathVars[i][0],PathVars[i][1],PathVars[i][2],PathVars[i][3],PathVars[i][4],PathVars[i][5]) then
        Begin
          Writeln('Walking to '+Which+': '+IntToStr(i+1)+' of '+IntToStr(hPathColor+1));
          FFlag(0);
          if (i = hPathColor) then
            Result := True;
          // ...
        End;
        // ...
      End;
    End;
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  6. #6
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

  7. #7
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Thank you! : )
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

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
  •