Results 1 to 6 of 6

Thread: Function help with TPA's

  1. #1
    Join Date
    Mar 2007
    Location
    Eugene, Oregon
    Posts
    195
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function help with TPA's

    I have this function in my script...

    SCAR Code:
    function FindTreeMS:boolean;
    var
    x, y, i, s: integer;
    MapleColor : Array [0..3] of Integer;
    Maple: TPointArray;
    MXY: TPoint;

    begin
     if not LoggedIn then exit;
      FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 15);
       if length(Maple) = 0 then
        begin
         FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 4);
        end;
       for i:= 0 to High(Maple) do
        MXY:= Maple[i];
         begin
          MMouse(MXY.X, MXY.Y, 3, 3);
          wait(100);
          if (pos('aple',rs_GetUpText) <> 0) then
           begin
            repeat
            GetMousePos(x, y);
            Result:= true;
            FindEnt(x, y, true);
            Mouse(x, y, 0, 0, true);
            wait(5000);
            AntiRandoms;
            until(InvFull);
           end;
          end;
         end;
     if not Result then
      begin
      MapleColor[0]:=27796;
      MapleColor[1]:=12911;
      MapleColor[2]:=27797;
      MapleColor[3]:=17015;
       for s:= 0 to 3 do
       if FindObjCustom(x, y, ['aple'], [MapleColor[s]], 4) then
        begin
         if IsUpText('aple') then
          begin
            repeat
            GetMousePos(x, y);
            FindEnt(x, y, true);
            Mouse(x, y, 0, 0, true);
            wait(5000);
            AntiRandoms;
            until(InvFull);
           end;
         end;
     end;

    I get these error when trying to compile, can someone help me with this and also tell me if it will do (correctly) what it looks like it is suppose to do lol (Which is find a maple tree color and cut the tree).

    Errors:
    Line 208: [Hint] (12936:1): Variable 'S' never used in script C:\Program Files\SCAR 3.15\Scripts\MyScripts\Tester.scar

    Line 209: [Hint] (12937:1): Variable 'MAPLECOLOR' never used in script C:\Program Files\SCAR 3.15\Scripts\MyScripts\Tester.scar

    Line 239: [Error] (12967:8): Unknown identifier 'Result' in script C:\Program Files\SCAR 3.15\Scripts\MyScripts\Tester.scar
    The [Hints]'s are there, looking this way, because the script isn't finding the second part of the function which is also the backup. I've just started with TPA's too so this stuff is rather confusing. If at all possible please explain a little of what you did to help

    EDIT: I just looked at something and do I need to add result as a variable? Becuase when i used a different variable boolean i used FindTree = True/false or whatnot and I got the error result never used in script so i took out the FindTree to use Result...

    EDIT: Also on the first half of the function should i use the base of the tree as the color to find there or should i leave it as a leaf color?

  2. #2
    Join Date
    Mar 2007
    Location
    Players[-1].Loc
    Posts
    962
    Mentioned
    4 Post(s)
    Quoted
    5 Post(s)

    Default

    This should work better for you
    SCAR Code:
    program New;
    {.include srl/srl.scar}
    function FindTreeMS:boolean;
    var
    x, y, i, s: integer;
    MapleColor : Array [0..3] of Integer;
    Maple: TPointArray;
    ATPA: T2DPointArray;
    MXY: TPoint;

    begin
     if not LoggedIn then exit;
      FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 15);
       if length(Maple) = 0 then
        begin
         FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 4);
        end;
       if Length(Maple) = 0 then Exit;
       ATPA := SplitTPA(Maple,5);
       SortATPASize(ATPA,True);
       for i:= 0 to High(ATPA) do
        begin
        MXY:= MiddleTPA(ATPA[i]);
          MMouse(MXY.X, MXY.Y, 3, 3);
          wait(100);
          if (pos('aple',rs_GetUpText) <> 0) then
           begin
            repeat
            GetMousePos(x, y);
            Result:= true;
            FindEnt(x, y, true);
            Mouse(x, y, 0, 0, true);
            wait(5000);
            AntiRandoms;
            until(InvFull);
           end;
          end;
     if not Result then
      begin
      MapleColor[0]:=27796;
      MapleColor[1]:=12911;
      MapleColor[2]:=27797;
      MapleColor[3]:=17015;
       for s:= 0 to 3 do
       if FindObjCustom(x, y, ['aple'], [MapleColor[s]], 4) then
        begin
         if IsUpText('aple') then
          begin
            repeat
            GetMousePos(x, y);
            FindEnt(x, y, true);
            Mouse(x, y, 0, 0, true);
            wait(5000);
            AntiRandoms;
            until(InvFull);
           end;
         end;
       end;
     end;

    begin
    end.

  3. #3
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    i also edited it, without adding T2DPointArray to it, keeping it just a TPA

    SCAR Code:
    function FindTreeMS:boolean;
    var
      x, y, i, s: integer;
      MapleColor : Array [0..3] of Integer;
      Maple: TPointArray;
      M: TPoint;

    begin
      if not LoggedIn then exit;
      FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 15);
      if length(Maple) = 0 then
        FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 25);
      for i:= 0 to High(Maple) do
      begin
        M.x:= Maple[i].x;
        M.y:= Maple[i].y;
        begin
          MMouse(M.x, M.y, 3, 3);
          wait(100);
          if (pos('aple',rs_GetUpText) <> 0) then
          begin
            repeat
              GetMousePos(x, y);
              Result:= true;
              FindEnt(x, y, true);
              Mouse(x, y, 0, 0, true);
              wait(5000);
              AntiRandoms;
            until(InvFull);
          end;
        end;
      end;
      if not Result then
      begin
        MapleColor[0]:=27796;
        MapleColor[1]:=12911;
        MapleColor[2]:=27797;
        MapleColor[3]:=17015;
        for s:= 0 to 3 do
        if FindObjCustom(x, y, ['aple'], [MapleColor[s]], 4) then
        begin
          if IsUpText('aple') then
          begin
            repeat
              GetMousePos(x, y);
              FindEnt(x, y, true);
              Mouse(x, y, 0, 0, true);
              wait(5000);
              AntiRandoms;
            until(InvFull);
          end;
        end;
      end;
    end;

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  4. #4
    Join Date
    Mar 2007
    Location
    Players[-1].Loc
    Posts
    962
    Mentioned
    4 Post(s)
    Quoted
    5 Post(s)

    Default

    I don't think he meant to check every single point on the TPA though (that's a lot of points =\).

  5. #5
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    this i know, im just showing another way, he might not understand exactly what a T2DPointArray is and how it works...

    EDIT: i noticed i didnt change the variables in GetMousePos and Mouse to the TPoint locations of M.x and M.y

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  6. #6
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Since neither of you mentioned the problem and just fixed it, it sounds you like you threw in an extra end; somewhere so it thought that the function had finished - most likely happened around here:
    SCAR Code:
    until(InvFull);
           end;
          end;
         end;
     if not Result then
      begin
    So proper indenting with begin's, end's etc. would've helped you to debug it more easily and find the problem
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. TPA's...
    By Floor66 in forum OSR Help
    Replies: 4
    Last Post: 03-01-2009, 06:47 PM
  2. Grouping TPA's
    By nielsie95 in forum OSR Advanced Scripting Tutorials
    Replies: 9
    Last Post: 12-10-2008, 05:56 AM
  3. Tpa's
    By lVlaverick in forum OSR Help
    Replies: 3
    Last Post: 09-13-2008, 06:14 PM
  4. TPA's explained.
    By mastaraymond in forum OSR Advanced Scripting Tutorials
    Replies: 18
    Last Post: 08-28-2008, 04:16 PM

Posting Permissions

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