Results 1 to 17 of 17

Thread: TPAFind! - Does a TPA's job in 1 LINE!

  1. #1
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TPAFind! - Does a TPA's job in 1 LINE!

    Hi =), 2bh i was realy fed up of having 2 write 20 odd lines of code for a tpa.. so i made this an include that doe's it for u!!!!!
    This Does Work ive tested it myself and only took 0.76 secs to find it and move the mouse to it!
    run thorugh of teh function:

    x and y - Were you whant your cords to be stored
    color 1 , 2 & 3 - 3 colours of the thing you are whanting to click
    TheUpText - the important part of the string at the top eg Oak (Case sensative)

    and there u have it we have located our object in 2 lines

    edit (lost count of the number of times XD):
    this sould work correctly has everything in it and uses TIntegerArray =)

    with special thank to Mastaraymond and ProphesyOfWolf For helping alot in the development of this Funciton!
    SCAR Code:
    Function TPAFind(Var X, y :integer; colors :TIntegerArray; TheUpText :String):boolean;
    var
      CTS, Ic : Integer;
      TPA: TPointArray;
      ATPA: Array of TPointArray;
      H, S, L, HueMod, SatMod, tolerance :extended;
      midcolor: integer;
      I,II : integer;
      HSLColor : Array[1..3] of Extended;
      HSL: Array[0..1] of Array[1..3] of Extended;
    begin
      //Work Out some values
      For Ic:= 1 to 3 do
      begin;
        HSL[0][ic] := 255; //Max is 240?
      end;
      For Ic:= 0 to High(Colors) do
      begin;
        ColortoHSL(Colors[ic],HSLColor[1],HSLColor[2],HSLColor[3]);
        For II:= 1 to 3 do
        begin;
          HSL[0][II] := MinE(HSLColor[II],HSL[0][II]);
          HSL[1][II] := MaxE(HSLColor[II],HSL[1][II]);
        end;
      end;
      For Ic:= 0 to 9 do
      begin;
      end;
      H := HSL[1][1] - HSL[0][1];
      S := HSL[1][2] - HSL[0][2];
      L := HSL[1][3] - HSL[0][3];
      midcolor := HSLToColor((HSL[1][1] + HSL[0][1]) div 2,(HSL[1][2] + HSL[0][2]) div 2,(HSL[1][3] + HSL[0][3]) div 2);
      HueMod := (H/L);
      SatMod := (S/L);
      tolerance := L;

      //FIND the TPA!
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Huemod, satmod );
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, MidColor, MSX1, MSY1, MSX2, MSY2, round(tolerance+0.5));
      ColorToleranceSpeed(CTS);
      ATPA := TPAToATPAEx(TPA, 15, 15);
      For Ic := 0 to High(ATPA) do
      begin
        MiddleTPAEx(ATPA[i], x, y);
        MMouse(x, y, 2, 2);
        Wait(50);
        If(IsUpTextMultiCustom([TheUpText])) then
        begin
          Result := True;
          GetMousePos(x, y);
          Break;
        end;
      end;
    end;

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    Function TPAFind(Var X, y :integer; colors :TIntegerArray; TheUpText :String):boolean;
    var
      CTS, Ic : Integer;
      TPA: TPointArray;
      ATPA: Array of TPointArray;
      H, S, L, HueMod, SatMod, tolerance :extended;
      midcolor: integer;
      I,II : integer;
      HSLColor : Array[1..3] of Extended;
      HSL: Array[0..1] of Array[1..3] of Extended;
    begin
      //Work Out some values
      For Ic:= 1 to 3 do
      begin;
        HSL[0][ic] := 255; //Max is 240?
      end;
      For Ic:= 0 to High(Colors) do
      begin;
        ColortoHSL(Colors[ic],HSLColor[1],HSLColor[2],HSLColor[3]);
        For II:= 1 to 3 do
        begin;
          HSL[0][II] := MinE(HSLColor[II],HSL[0][II]);
          HSL[1][II] := MaxE(HSLColor[II],HSL[1][II]);
        end;
      end;
      For Ic:= 0 to 9 do
      begin;
      end;
      H := HSL[1][1] - HSL[0][1];
      S := HSL[1][2] - HSL[0][2];
      L := HSL[1][3] - HSL[0][3];
      midcolor := HSLToColor((HSL[1][1] + HSL[0][1]) div 2,(HSL[1][2] + HSL[0][2]) div 2,(HSL[1][3] + HSL[0][3]) div 2);
      HueMod := (H/L);
      SatMod := (S/L);
      tolerance := L;

      //FIND the TPA!
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Huemod, satmod );
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, MidColor, MSX1, MSY1, MSX2, MSY2, round(tolerance+0.5));
      ColorToleranceSpeed(CTS);
      ATPA := TPAToATPAEx(TPA, 15, 15);
      For Ic := 0 to High(ATPA) do
      begin
        MiddleTPAEx(ATPA[i], x, y);
        MMouse(x, y, 2, 2);
        Wait(50);
        If(IsUpTextMultiCustom([TheUpText])) then
        begin
          Result := True;
          GetMousePos(x, y);
          Break;
        end;
      end;
    end;
    var
      OakColors :TIntegerArray;
      x, y, T :integer;

    begin
    SetUpSRL;
    marktime(t);
    //Change the below ;)
    OakColors := [2582619, 2185550, 2384468]// or your own colors
    TpaFind(x, y, OakColors, 'Oak');// or your TPA values
    //Injoy =)
    mouse(x, y, 2, 2, true);
    writeln('Took '+inttostr(TimeFromMark(t))+'To Find Your Object!');
    end.

  2. #2
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Wow, all's you are doing is pumping out the scripts man! Your going to have SRL members in no time! I looked at the actual function. Do you program aany other language? It seems like you have been doing this a long time. Good job!!!!
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  3. #3
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    lolz thz =) only basic javascript and html i just realy like scar an ammasing laguage 2 script in and im making a script for members i just had this though half way through XD

  4. #4
    Join Date
    Mar 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I dit this and get this error

    SCAR Code:
    Line 132: [Error] (17650:9): Unknown identifier 'x' in script C:\Program Files\SCAR 3.15c\Scripts\Guild miner.scar

    line132
    SCAR Code:
    TPAFind(x, y, 3433856, 3297377, 4155003, 'Ladder');

  5. #5
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    umm have u declered x and y as a var?
    have u include it as an include eg {.include SRL/TpaFind.scar}
    and that just returns teh x and y if u whant 2 click remember mouse(x,y,2,2,true);

  6. #6
    Join Date
    Mar 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If have just copyd youre function putted in my script and than just used it at line 132

    ---------
    Or do i need to add mouse(x,y,2,2,true); at function or where ?

  7. #7
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    What if I have 2 colors? Ten?
    SCAR Code:
    function TPAFind(Var X, y :integer; colors:TintegerArray; TheUpText :String):boolean;
    var
      CTS, Ic : Integer;
      TPA: TPointArray;
      ATPA: Array of TPointArray;
      H, S, L, HueMod, SatMod, tolerance :extended;
      midcolor: integer;
      HueString, SatString:string;
      I,II : integer;
      HSLColor : Array[1..3] of Extended;
      HSL: Array[0..1] of Array[1..3] of Extended;
    begin
      //Work Out some values
      For Ic:= 1 to 3 do
      begin;
        HSL[0][ic] := 255; //Max is 240?
      end;
      For Ic:= 0 to High(Colors) do
      begin;
        ColortoHSL(Colors[ic],HSLColor[1],HSLColor[2],HSLColor[3]);
        For II:= 1 to 3 do
        begin;
          HSL[0][II] := MinE(HSLColor[II],HSL[0][II]);
          HSL[1][II] := MaxE(HSLColor[II],HSL[1][II]);
        end;
      end;
      For Ic:= 0 to 9 do
      begin;
      end;
      H := HSL[1][1] - HSL[0][1];
      S := HSL[1][2] - HSL[0][2];
      L := HSL[1][3] - HSL[0][3];
      midcolor := HSLToColor((HSL[1][1] + HSL[0][1]) div 2,(HSL[1][2] + HSL[0][2]) div 2,(HSL[1][3] + HSL[0][3]) div 2);
      HueMod := (H/L);
      SatMod := (S/L);
      tolerance := L;
      Huestring := floattostr(HueMod);
      SatString := floattostr(SatMod);
      setlength(HueString,4);
      setlength(SatString,4);
      //FIND the TPA!
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(StrToFloat(HueString), StrToFloat(SatString));
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, MidColor, MSX1, MSY1, MSX2, MSY2, round(tolerance+0.5));
      ColorToleranceSpeed(CTS);
      ATPA := TPAToATPAEx(TPA, 15, 15);
      For Ic := 0 to High(ATPA) do
      begin
        MiddleTPAEx(ATPA[i], x, y);
        MMouse(x, y, 2, 2);
        Wait(50);
        If(IsUpTextMultiCustom([TheUpText])) then
        begin
          Result := True;
          GetMousePos(x, y);
          Break;
        end;
      end;
    end;
    Shorter and better.

  8. #8
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i was thinking of somthing aloung thoughs lines but u ahve declear all the values b4 hand.. =\ altough i suppose u could just put:
    OakTPAColors := [908921, 988273, 1872632]
    in the setup and then call
    TPAFind(x, y, OakTpaColors, 'Oak');

    EDIT: changed it to a TIntegerArray injoy secounds not 10 mins of happy coding

  9. #9
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Nope you don't

    TPAFind(x, y, [908921, 988273, 1872632], 'Oak');

  10. #10
    Join Date
    Mar 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    can't you make a const of it

    of:
    OakColors := [908921, 988273, 1872632]

    -------------------
    I get a error when he try to do FindTPA

    [Runtime Error] : Exception: Invalid float in line 104 in script C:\Program Files\SCAR 3.15c\Scripts\Guild miner.scar
    @104

    SCAR Code:
    SetColorSpeed2Modifiers(StrToFloat(HueString), StrToFloat(SatString));

  11. #11
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    umm yer both ways work very well =)
    or u can use things like:
    case treetype of
    'Oak': colors := [143512,2522454,396523]

  12. #12
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Double post is phail.

    And. Just make it use a TIntegerArray;, with the user setting up the Color array in the Players[] setup.

  13. #13
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yer gud enough and i think i may know y that error has appreared do 1 of 2 things
    1. use difrent colors
    2.use this script insted:
    SCAR Code:
    function TPAFind(Var X, y :integer; colors :TIntegerArray; TheUpText :String):boolean;
    var
      CTS, Ic : Integer;
      TPA: TPointArray;
      ATPA: Array of TPointArray;
      H, S, L, HueMod, SatMod, tolerance :extended;
      midcolor: integer;
      HueString, SatString:string;
      I,II : integer;
      HSLColor : Array[1..3] of Extended;
      HSL: Array[0..1] of Array[1..3] of Extended;
    begin
      //Work Out some values
      For Ic:= 1 to 3 do
      begin;
        HSL[0][ic] := 255; //Max is 240?
      end;
      For Ic:= 0 to High(Colors) do
      begin;
        ColortoHSL(Colors[ic],HSLColor[1],HSLColor[2],HSLColor[3]);
        For II:= 1 to 3 do
        begin;
          HSL[0][II] := MinE(HSLColor[II],HSL[0][II]);
          HSL[1][II] := MaxE(HSLColor[II],HSL[1][II]);
        end;
      end;
      For Ic:= 0 to 9 do
      begin;
      end;
      H := HSL[1][1] - HSL[0][1];
      S := HSL[1][2] - HSL[0][2];
      L := HSL[1][3] - HSL[0][3];
      midcolor := HSLToColor((HSL[1][1] + HSL[0][1]) div 2,(HSL[1][2] + HSL[0][2]) div 2,(HSL[1][3] + HSL[0][3]) div 2);
      HueMod := (H/L);
      SatMod := (S/L);
      tolerance := L;
     
      //FIND the TPA!
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Huemod, satmod );
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, MidColor, MSX1, MSY1, MSX2, MSY2, round(tolerance+0.5));
      ColorToleranceSpeed(CTS);
      ATPA := TPAToATPAEx(TPA, 15, 15);
      For Ic := 0 to High(ATPA) do
      begin
        MiddleTPAEx(ATPA[i], x, y);
        MMouse(x, y, 2, 2);
        Wait(50);
        If(IsUpTextMultiCustom([TheUpText])) then
        begin
          Result := True;
          GetMousePos(x, y);
          Break;
        end;
      end;
    end;

  14. #14
    Join Date
    Mar 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Can you add the example back when you wanna quick test it

  15. #15
    Join Date
    Jun 2007
    Location
    south park
    Posts
    1,160
    Mentioned
    0 Post(s)
    Quoted
    62 Post(s)

    Default

    if i use thisin my members appiclation il get bitched at for using a to simple script!
    http://www.youtube.com/user/YoHoJoSRL
    Good scripting guides on youtube
    Formerly known as (djcheater)

  16. #16
    Join Date
    Nov 2007
    Location
    The Netherlands
    Posts
    1,490
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I made this also
    Your not the first one
    A lot could be shortened, but overall, good job!

    PvH

  17. #17
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    There was 1 befor? dang XD ill take a look in a sec and yer ill add the test bak

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
  5. Function help with TPA's
    By FuruChan in forum OSR Help
    Replies: 5
    Last Post: 06-28-2008, 11:44 AM

Posting Permissions

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