Results 1 to 6 of 6

Thread: need help with this function/procedure

  1. #1
    Join Date
    Feb 2012
    Posts
    125
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default need help with this function/procedure

    Simba Code:
    function A_FindObj(color, tol, count : integer; uptext : string; left : boolean): Boolean;
    var
      X, Y, A, M, curCTS: Integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;

    begin
      Result := False;
      if not LoggedIn then exit;
      curCTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, tol) then
        begin
          ColorToleranceSpeed(1);
          writeln('Cannot find color');
          exit;
        end;
        ColorToleranceSpeed(1);
        ATPA := TPAtoATPAEx(TPA, 10, 10);
        M := High(ATPA);
        for A := 0 to M do
        begin
          if Length(ATPA[A]) < count then
            continue;
          if MiddleTPAEx(ATPA[A], X, Y) then
          begin
            MMouse(X, Y, 6, 6);
            Wait(100 + Random(50));
            if WaitUptext(uptext, 100) then
            begin
              GetMousePos(X, Y);

              Mouse(X, Y, 0, 0, left);
              Result := True;
              ColorToleranceSpeed(curCTS);
              Exit;
            end;
          end;
        end;
      ColorToleranceSpeed(curCTS);
    end;

    I'm trying to use this to detect the range in catherby. And this is what i have so far.

    Simba Code:
    procedure clickthisitem;
    begin
      mouseitem(1, 0);
     end;
    function if A_FindObj(rangecol, 10, 10, 'ange', true) then
    var
          X, Y, A, M, curCTS: Integer;
          TPA: TPointArray;
          ATPA: T2DPointArray;

    begin
     Result := False;
      if not LoggedIn then exit;
      curCTS := GetColorToleranceSpeed;
          ColorToleranceSpeed(2);
          if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2962580, 5339537, MSX1, MSY1, MSX2, MSY2, tol) then
          begin
            ColorToleranceSpeed(1);
            writeln('Cannot find color');
            exit;
          end;
          ColorToleranceSpeed(1);
          ATPA := TPAtoATPAEx(TPA, 10, 10);
          M := High(ATPA);
          for A := 0 to M do
          begin
            if Length(ATPA[A]) < count then
              continue;
            if MiddleTPAEx(ATPA[A], X, Y) then
            begin
              MMouse(X, Y, 6, 6);
              Wait(100 + Random(50));
              if WaitUptext(uptext, 100) then
              begin
                GetMousePos(X, Y);

                Mouse(X, Y, 0, 0, left);
                Result := True;
                ColorToleranceSpeed(curCTS);
                Exit;
              end;
            end;
          end;
      ColorToleranceSpeed(curCTS);
    end;

    I keep getting the error

    Simba Code:
    [Error] (27:10): Identifier expected at line 26


    I'm so lost atm...

  2. #2
    Join Date
    Feb 2012
    Posts
    125
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This is line 26 btw
    Simba Code:
    function if A_FindObj(rangecol, 10, 10, 'ange', true) then

  3. #3
    Join Date
    Jan 2012
    Location
    Calgary, AB, Canada
    Posts
    1,819
    Mentioned
    5 Post(s)
    Quoted
    120 Post(s)

    Default

    There are major flaws at the beginning there, you have a if..then function as the title of your function. You need to move that else where and you need to specify the type of function I just made it boolean

    Simba Code:
    function FindSomething: Boolean; // This entire area is messed up
     if A_FindObj(rangecol, 10, 10, 'ange', true) then  //Not sure what your trying to do with this but this is a if..then function
    var
          X, Y, A, M, curCTS: Integer;
          TPA: TPointArray;
          ATPA: T2DPointArray;

    begin
     Result := False;
      if not LoggedIn then exit;
      curCTS := GetColorToleranceSpeed;
          ColorToleranceSpeed(2);
          if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2962580, 5339537, MSX1, MSY1, MSX2, MSY2, tol) then
          begin
            ColorToleranceSpeed(1);
            writeln('Cannot find color');
            exit;
          end;
          ColorToleranceSpeed(1);
          ATPA := TPAtoATPAEx(TPA, 10, 10);
          M := High(ATPA);
          for A := 0 to M do
          begin
            if Length(ATPA[A]) < count then
              continue;
            if MiddleTPAEx(ATPA[A], X, Y) then
            begin
              MMouse(X, Y, 6, 6);
              Wait(100 + Random(50));
              if WaitUptext(uptext, 100) then
              begin
                GetMousePos(X, Y);

                Mouse(X, Y, 0, 0, left);
                Result := True;
                ColorToleranceSpeed(curCTS);
                Exit;
              end;
            end;
          end;
      ColorToleranceSpeed(curCTS);
    end;

    Just looks like you have no clue what your doing, I suggest you looks at some beginner tutorials
    Current Project: Retired

  4. #4
    Join Date
    Feb 2012
    Posts
    125
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    this whole tpa thing is confusing me.

    I was trying to make it find the rage uptext there. Guess I'll head back to the tutorials.

  5. #5
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Well I hope it was common knowledge that you can't name a function:
    Simba Code:
    if A_FindObj(rangecol, 10, 10, 'ange', true) then

    You have to actually give it a name and declare the variables before starting it.

  6. #6
    Join Date
    Feb 2012
    Posts
    125
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It is now.
    lakjsdpofiuasklfoaiuselrkjpaoiufd < -- How I feel.

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
  •