Results 1 to 9 of 9

Thread: What is going on with this?

  1. #1
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default What is going on with this?

    I need to count an item in my inventory. I don't want to use a DTM if I don't have to because I'm trying to just use tpa's.

    Here's the code:
    SCAR Code:
    function FlaxAmount: Integer;
    var x, y, i,a: Integer; iBox: TBox; Arr: array of TPoint;
    begin
      if not LoggedIn then Exit;
      for i := 1 to 28 do
      begin
        iBox := InvBox(i);
        Arr := GetColorPoints(x, y, 12433750, iBox.x1, iBox.y1, iBox.x2, iBox.y2, 1, 1, 10);
        if Length(Arr) > 5 then
          Inc(Result);
      end;
    end;

    I am testing with only 1 flax in my inventory and it is in the second slot.
    For some reason, the function keeps returning 0 or 27 or 14.

    Any thoughts?


    For those wondering:
    SCAR Code:
    {*******************************************************************************
    function GetColorPoints(x, y, Color, bp1, bp2, bp3, bp4, Width, Height, Tol: Integer): TPointArray;
    By: NCDS
    Description: Finds and Stores points defined by 'Color' and bp[1..4].
    Also checks width, height and allows for tolerance.
    *******************************************************************************}
    GetColorPoints(); works fine, I use it in many other functions.
    Last edited by NCDS; 08-17-2009 at 03:34 AM.

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

    Default

    Paste the function 'GetColorPoints', on a sidenote use Inc(v) instead of v := v + 1;

    EDIT: And the code
    Last edited by Naum; 08-17-2009 at 03:33 AM.

  3. #3
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Paste the function 'GetColorPoints', on a sidenote use Inc(v) instead of v := v + 1;
    Edited.

  4. #4
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Paste the function 'GetColorPoints', on a sidenote use Inc(v) instead of v := v + 1;
    SCAR Code:
    v := v + 1;
    Is faster, because Mastaraymond says so.
    ~Hermen

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

    Default

    Debate: http://www.villavu.com/forum/showthread.php?t=35347

    Also NCDS try raising the Height and the Width, if it's a 1x1 pixel square there is no way you can get 5 pixels out of that.

  6. #6
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Why not just use a simple FindColorsSpiralTolerance? This worked just fine for me (returned 3 when there were 3 in inventory).

    SCAR Code:
    function FlaxAmount: Integer;
    var x, y, i,a: Integer; iBox: TBox; TPA: TPointArray;
    begin
      if not LoggedIn then Exit;
      for i := 1 to 28 do
      begin
        iBox := InvBox(i);
        FindColorsSpiralTolerance(x, y, TPA, 12433750, iBox.x1, iBox.y1, iBox.x2, iBox.y2, 10);
        if Length(TPA) > 5 then
          Result := Result + 1;
      end;
    end;

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

    Default

    Why not even just use a countcolor of the black pixels around the flax? Its the most simple, and most quick way to do it ^.^
    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

  8. #8
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by JAD View Post
    Why not just use a simple FindColorsSpiralTolerance? This worked just fine for me (returned 3 when there were 3 in inventory).

    SCAR Code:
    function FlaxAmount: Integer;
    var x, y, i,a: Integer; iBox: TBox; TPA: TPointArray;
    begin
      if not LoggedIn then Exit;
      for i := 1 to 28 do
      begin
        iBox := InvBox(i);
        FindColorsSpiralTolerance(x, y, TPA, 12433750, iBox.x1, iBox.y1, iBox.x2, iBox.y2, 10);
        if Length(TPA) > 5 then
          Result := Result + 1;
      end;
    end;
    Yeah that works thanks JAD. I just don't understand why my GetColorPoints(); didn't work for it. It works great for everything else.

  9. #9
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by noidea View Post
    Why not even just use a countcolor of the black pixels around the flax? Its the most simple, and most quick way to do it ^.^
    Because there may be other objects with just as many black pixels as flax have, and the current procedure NCDS have counts the light-blue pixels of the flax (or something similar)
    EDIT: NCDS; GetColorPoints didn't work because you, as NaumanAkhlaQ stated before, put 1px as width and 1px as height and there is no way you can get 5 pixels inside 1px.

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
  •