Results 1 to 23 of 23

Thread: Object.scar Shorten

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

    Default Object.scar Shorten

    SCAR Code:
    {*******************************************************************************
    function FindObjTPAMulti(var X, Y: integer; Color: TIntegerArray; Tol, CTS, ObjWidth, ObjHeight, minCount :Integer; UpText: TStringArray): Boolean;
    By: Wizzup?
    Description: This is a modification of FindObjTPA, which uses a TIntegerArray for the Colors.
    Date: 29th August 2009
    *******************************************************************************}

    function FindObjTPAMulti(var X, Y: Integer; Colour: TIntegerArray; Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: TStringArray): Boolean;
    var
      i, tCTS: Integer;
      myPoint: TPoint;
      aPoints: T2DPointArray;
      ATPA: T2DPointArray;
      TPA: TPointArray;
    begin
      Result := False;
      if not LoggedIn then exit;
      tCTS := GetColorToleranceSpeed;
      if CTS * 9 mod 3 <> 0 then
        CTS := 1;
      ColorToleranceSpeed(CTS);
      SetLength(ATPA, Length(Colour));
      for i := 0 to High(Colour) do
      begin
        FindColorsSpiralTolerance(x, y, ATPA[i], Colour[i], MSX1, MSY1, MSX2, MSY2, Tol);
      end;
      TPA := MergeATPA(ATPA);
      if Length(TPA) = 0 then
      begin
        ColorToleranceSpeed(tCTS);
        Exit;
      end;
      ColorToleranceSpeed(1);
      aPoints := TPAtoATPAEx(TPA, ObjWidth, ObjHeight);
      for I := 0 to High(aPoints) do
      begin
        if Length(aPoints[i]) < minCount then
          Continue;
        myPoint := MiddleTPA(aPoints[i]);
        MMouse(myPoint.x, myPoint.y, 0, 0);
        if WaitUpTextMulti(UpText, 300) then
        begin
          GetMousePos(X, Y);
          Result := True;
          ColorToleranceSpeed(tCTS);
          Exit;
        end;
      end;

      ColorToleranceSpeed(tCTS);
    end;
    {*******************************************************************************
    function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray): Boolean;
    By: Wizzup?
    Description: Finds object using WizzyPlugin functions.
    Starts with a Spiral from x and y.
    Put in the color, Tolerance and ColorToleranceSpeed.
    If you don't know what colortolerancespeed to choose, put in -1.
    ObjWidth and ObjHeight are the parameters TPAToATPAEx uses, thus filtering
    the MS's FindColorsSpiralTolerance points in boxes defined by
    ObjWidth and ObjHeigth.
    minCount is the amount of colors it should at least find in a Object box.
    UpText, is ofcourse the text the object should have. In the Multi variant the
    UpText is a string array.

    *******************************************************************************}


    function FindObjTPA(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: TStringArray): Boolean;
    begin
      Result:=FindObjTPAMulti(X, Y, [Color], Tol, CTS, ObjWidth, ObjHeight, minCount, UpText);
    end;

    Just a little shorten

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Good work, I can't believe I hadn't spotted it . Rep++

    Just while we're at it:

    SCAR Code:
    if CTS * 9 mod 3 <> 0 then
        CTS := 1;

    to:

    SCAR Code:
    CTS := Integer(CTS * 9 mod 3 <> 0);


    Furthermore:


    SCAR Code:
    for i := 0 to High(Colour) do
      begin
        FindColorsSpiralTolerance(x, y, ATPA[i], Colour[i], MSX1, MSY1, MSX2, MSY2, Tol);
      end;

    to:

    SCAR Code:
    for i := 0 to High(Colour) do
        FindColorsSpiralTolerance(x, y, ATPA[i], Colour[i], MSX1, MSY1, MSX2, MSY2, Tol);

  3. #3
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    The hell, I wrote FindObjTPAMutli :P

    Well. Modded it.

    n2 edit: no swears, son.
    Last edited by Nava2; 10-25-2009 at 06:46 PM. Reason: no swearing, son.
    Jus' Lurkin'

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

    Default

    Quote Originally Posted by Torrent of Flame View Post
    The hell, I wrote FindObjTPAMutli :P

    Well. Modded it.

    n2 edit: no swears, son.
    Modded wizzup's code, so basicly, since his code was gone I thought he technically wrote it so he should get credit. The devs can decide who to give credit to.

  5. #5
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by MylesMadness View Post
    Modded wizzup's code, so basicly, since his code was gone I thought he technically wrote it so he should get credit. The devs can decide who to give credit to.
    true true. fair gain son.
    Jus' Lurkin'

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

    Default

    Bump, this still isn't done...

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

    Default

    Still hasn't been done...

  8. #8
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Maybe go rape someones private in irc?
    There used to be something meaningful here.

  9. #9
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Who cares -_-.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  10. #10
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Naum View Post
    Good work, I can't believe I hadn't spotted it . Rep++

    Just while we're at it:

    SCAR Code:
    if CTS * 9 mod 3 <> 0 then
        CTS := 1;

    to:

    SCAR Code:
    CTS := Integer(CTS * 9 mod 3 <> 0);
    Please don't do this. It's not a proper way of coding. It makes several assumption that aren't really viable, and it is less readable too.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  11. #11
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Please don't do this. It's not a proper way of coding. It makes several assumption that aren't really viable, and it is less readable too.
    That was roughly half a dozen months ago. My fixation with distilling code has long since passed.
    On another note, would someone please be able to commit this? (since i can't atm)

  12. #12
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I never found object.scar to be useful.

  13. #13
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    I never found object.scar to be useful.
    its useful for the newbs that haven't learned tpas yet
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  14. #14
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    I never found object.scar to be useful.
    Just because you don't, doesn't mean other people don't.

  15. #15
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Just because you don't, doesn't mean other people don't.
    That comma doesn't belong there.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  16. #16
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Naum View Post
    That was roughly half a dozen months ago. My fixation with distilling code has long since passed.
    On another note, would someone please be able to commit this? (since i can't atm)
    Whoops. Sorry!
    We'll fix you an account soon, too.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  17. #17
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Whoops. Sorry!
    We'll fix you an account soon, too.
    Please and thank-you.

  18. #18
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Code:
      if CTS * 9 mod 3 <> 0 then
        CTS := 1;
    That has no purpose. If an integer is multiplied by 9, it will always be divisible by 3.

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

    Default

    Quote Originally Posted by bullzeye95 View Post
    Code:
      if cts * 9 mod 3 <> 0 then
        cts := 1;
    that has no purpose. If an integer is multiplied by 9, it will always be divisible by 3.
    cts = 0?

  20. #20
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Even in that case, it still returns 0.

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

    Default

    So CTS will always be one?

  22. #22
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Yes. You catch on quick.

  23. #23
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by MylesMadness View Post
    So CTS will always be one?
    No, CTS will always be the one in the parameter.
    CTS * 9 mod 3 <> 0
    always returns false, so the "then" statement will never be called.

    E: Now that I look at the function, I see that
    FindColorsSpiralTolerance(x, y, ATPA[i], Colour[i], MSX1, MSY1, MSX2, MSY2, Tol);
    always starts searching from variables x, y which will most likely be 0, 0. Should be changed to MSCX, MSCY.
    Last edited by marpis; 05-16-2010 at 06:30 PM.

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
  •