Results 1 to 13 of 13

Thread: Count Feathers in Inventory

  1. #1
    Join Date
    Sep 2008
    Location
    Nova Scotia, Canada
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Count Feathers in Inventory

    Anybody have a code snippet that will correctly count the number of feathers in your inventory? Specifically when you have > 10000 feathers.

    I've tried ItemAmount and CountItems with a couple of different DTMs scoured from various scripts/threads, as well as the countfeathers routine from ForeFeathers.

    All give the same result, returning the middle 3 digits (Ex: 23761 returns 376). Well except for CountItems which is consistently inconsistent for me, returning 0 more often than not.

    If I have less than 10000 feathers they work. And If I have between 10000 - 19999 they return the last 4 digits sometimes. Very frustrating when such a simple thing doesn't work.

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

    Default

    Use a TPA then use GetTPABounds to the box you want to look for the number in.
    Then look and see if the number has the letter k next to if it does, just multiply the number by 1000.

    Like

    SCAR Code:
    var
      TPA: TPointArray;
      Boxeh: TBox;
      S: String;
    begin
      FindColorsTOlerance(TPA, Col, x1, y1, x2, y2, Tol);
      Boxeh := GetTPABounds(TPA);
      s := GetTextAtEX();
      If Pos('K', S) then
        TrimText
      ect..
    Last edited by noidea; 08-07-2009 at 06:14 AM.
    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
    Sep 2008
    Location
    Nova Scotia, Canada
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    When in your inventory it does not use the 'K' notation. It displays the exact amount (ie 12345). Haven't tried for > 100000 feathers.

    Perhaps this is something that silently changed with one of the RuneScape updates? All the scripts I see seem to assume the K will be used. Or is that only in your Bank that it does that?
    http://www.stats.srl-forums.com/sigs/6137.png

    If I see you autoing with level 3/default clothes/crap name I WILL report you. Auto Correctly. - Put this in your sig.

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

    Default

    Quote Originally Posted by spamthis View Post
    When in your inventory it does not use the 'K' notation. It displays the exact amount (ie 12345). Haven't tried for > 100000 feathers.

    Perhaps this is something that silently changed with one of the RuneScape updates? All the scripts I see seem to assume the K will be used. Or is that only in your Bank that it does that?
    no silly.
    It uses k when it gets to 100,000
    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

  5. #5
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Reflection FTW (inventory.scar):
    PHP Code:
    {*******************************************************************************
    function 
    R_CountItemsStacks(ID Integer) : Integer;
    ByNava2
    Description
    Returns amount of Item of ID in the inventorycounting stacks.
    *******************************************************************************}

    function 
    R_CountItemsStacks(ID Integer) : Integer;

    var
      
    InvIInteger;

    begin
      Result 
    := 0;
      
    Inv := GetInterface(1490);
      for 
    := 0 to 27 do
        if 
    SmartGetFieldArrayInt(InvInventoryItemIDsi) = ID then
          Result 
    := Result SmartGetFieldArrayInt(InvInventoryItemStackSizesi);
      
    SmartFreeObject(Inv);
    end
    So:

    SCAR Code:
    Procedure CountFeather;
    begin
      if R_CountItemStacks(FeatherID) >= 100000 then
      Writeln('Feathers have reached over 100k');
    end;

    Or in color(amount.scar):

    PHP Code:
    {*******************************************************************************
    function 
    ItemAmount(AreaItemTypestringItemIntegerTolTIntegerArray): Integer;
    Bymasquerader modified by ZephyrsFury
    Description
    Counts the number of items found with a color in a certain area. (Counts stacks)
    Parameters:
      
    Area 'inv''shop''bank''trade''your trade'.
      
    ItemType 'dtm''bmp''color''bmpmask'.
      
    Item name/value of your dtm/bmp/color/bmpmask.
      
    Tol 'dtm' - [] (dtm's can't have tolerance).
            
    'bmp' - [BMPTol].
            
    'color' - [COLOUR TolMin Colour Count].
            
    'bmpmask' - [BMPTolContourTol].
    *******************************************************************************}

    function 
    ItemAmount(areaItemTypestringItemIntegerTolTIntegerArray): Integer;
    var
      
    CoordsTPointArray;
      
    ihInteger;
    begin
      Result 
    := 0;
      
    Coords := ItemCoordinates(AreaItemTypeItemTol);
      
    := High(Coords);
      for 
    := 0 to h do
        
    Result := Result GetAmount(Coords[i].xCoords[i].y);
    end
    So:

    SCAR Code:
    Procedure CountFeather;
    Var
       Feathers, FeatherColor: integer;
    begin
      FeatherColor := 234235; //note that isn't actual feather color
      Tolerance := 15; //could be anything really
      if ItemAmount('inv', 'color', FeatherColor, Feathers, [Tolerance, 1]) > 100000 then
      begin
        Writeln('You have' + IntToStr(Feather) + 'feathers');
    end;

    I used a color, you could use a bitmap though.(or dtm)

    Hope it helps!

  6. #6
    Join Date
    Sep 2008
    Location
    Nova Scotia, Canada
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Smarter Child, I know you meant to help, but my point was these routines DO NOT work for me. They return inaccurate results. I was not confused on how to use the routines, but rather disappointed they return inaccurate results.

    To show you what I mean I ran the following code with 2545 feathers in inventory slot 11:
    Code:
      FeatherDTM:= DTMFromString('78DA637461626078C28002D62C5CC06003A41' +
           '981F83F1030FA02D55C6740038C482490F600AA794E408D0D50CD' +
           '5B026AEC806A1EE257030001080C01');
      if (FindDTM(FeatherDTM, X, Y, MIX1, MIY1, MIX2, MIY2)) then
      begin
        writeln('Found!');
        InvSlot := CoordsToItem(X, Y);
        writeln('Inventory Slot: ' + IntToStr(InvSlot));
        FeatherCount := ItemAmount('inv', 'dtm', FeatherDTM, []);
        writeln('ItemAmount (Using DTM): ' + IntToStr(FeatherCount) + ' Feathers.');
        FeatherCount := ItemAmount('inv', 'color', 11382200, [15, 1]);
        writeln('ItemAmount (Using Color): ' + IntToStr(FeatherCount) + ' Feathers.');
        FeatherCount := CountItems('dtm', FeatherDTM, []);
        writeln('CountItems: ' + IntToStr(FeatherCount) + ' Feathers.');
        exit;
      end;
    ...And got the following results:
    Code:
    Found!
    Inventory Slot: 11
    ItemAmount (Using DTM): 545 Feathers.
    ItemAmount (Using Color): 545 Feathers.
    CountItems: 1 Feathers.
    Successfully executed
    If the amount of feathers had been 25450 it would have still returned 545 (the middle 3 chars).

    Either it's broken or I'm seriously missing something. I'm not excluding either possibility.

    noidea, I will give your suggestion a go tomorrow. To be honest my brain is too fried from a long day at work to think my way through it.
    http://www.stats.srl-forums.com/sigs/6137.png

    If I see you autoing with level 3/default clothes/crap name I WILL report you. Auto Correctly. - Put this in your sig.

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

    Default

    CountItems, does in your way of using only count the items(not the stack).
    ~Hermen

  8. #8
    Join Date
    Sep 2008
    Location
    Nova Scotia, Canada
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Doh!

    Ah! That explains that little mystery.

    Guess trying to read the forums, peruse the SRL includes, work on my test scripts, watch over my running bots, and watch tv while dog tired is probably a bad idea.

    Misread how CountItems works. Not always clear from the description in the includes.
    http://www.stats.srl-forums.com/sigs/6137.png

    If I see you autoing with level 3/default clothes/crap name I WILL report you. Auto Correctly. - Put this in your sig.

  9. #9
    Join Date
    Sep 2008
    Location
    Nova Scotia, Canada
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    noidea,

    Could you be just a little more specific on your example. It's not much help as is. While I normally agree with giving some hints to get a person going, sometimes it is actually more productive to give a working example that a person can study.

    Getting the number of feathers in your inventory is a very minor part of any script and should be as simple as a function call. To have to write pages of semi-advanced code just to get the count seems to defeat the purpose of trying to learn SRL.

    ItemAmount does not work as documented. That was my whole point! I've been browsing around the forums and reading every chicken killer script I can and I notice every single chicken killer script out there returns incorrect feather counts! Nobody has it working because they are counting on ItemAmount working as documented. Take a very close look at the progress reports from the scripts out there, you'll see what I mean.

    Writing a replacement for ItemAmount is beyond me at this point. So I asked if anyone has a snippet of code that works, so I can concentrate on writing a script so I can learn. I am just going to take it out until it gets fixed. Its really not that important to count the feathers; It just irks me that such a simple thing should be so insanely complicated.
    Last edited by spamthis; 08-09-2009 at 11:40 PM.
    http://www.stats.srl-forums.com/sigs/6137.png

    If I see you autoing with level 3/default clothes/crap name I WILL report you. Auto Correctly. - Put this in your sig.

  10. #10
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    He uses a little more advanced technique, if you need any help just add me on msn:

    wowplayermaster@hotmail.com

  11. #11
    Join Date
    Sep 2008
    Location
    Nova Scotia, Canada
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm just going to take it out. While using your own advanced custom technique is nice, it would be nice if someone occasionally went back and made sure the built in routines actually work.

    This leaves those just starting out completely screwed: The built in routines don't work and those that have working routines are not sharing.

    Just for giggles here are the results I got with the ItemAmount function:

    Actual - Returned Result
    7 1
    70 0
    870 70
    7870 870
    17870 7870
    27870 787
    37870 7870


    Not one correct result.

    I don't actually need this, as I decided to work on something else. I just wanted to get it working before moving on: I will need accurate counting in what I want to work on anyway.

    Edt: I'd report this as a bug, but that sub-forum doesn't exist: It's a dead link.
    Last edited by spamthis; 08-10-2009 at 12:19 AM.
    http://www.stats.srl-forums.com/sigs/6137.png

    If I see you autoing with level 3/default clothes/crap name I WILL report you. Auto Correctly. - Put this in your sig.

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

    Default

    update to the SRL dev repository and use getamount, If you need exact for 100K + I have a function that examines in the SRL public SVN Core forum. GetCointAmountEx.


    From Amount.SCAR in the newest Dev Repository.
    Code:
    {*******************************************************************************
    function GetAmount(ItemX, ItemY: Integer): Integer;
    By: Zeph & N1ke!
    Description: Returns the amount of an item at coordinates (ItemX, ItemY).
      Returns approximate values for 'K' and 'M'.
    *******************************************************************************}
    Function GetAmount(ItemX, ItemY: Integer): Integer;
    var
      Col: TIntegerArray;
      X, Y, I: Integer;
      S: String;
    begin
      If Not FindColor(X, Y, 65536, ItemX-30, ItemY-30, ItemX+30, ItemY+30)then
        Exit;
      Col := [65535, 16777215, 8453888];
      For I:=0 to 2 do
       If FindColor(X, Y, Col[I], ItemX-22, ItemY-22, ItemX+22, ItemY+22)then
       begin
         S := Trim(GetTextAtEx(X-2, Y-1, 0, StatChars, False, False, 0, 1, Col[I], 5, True, tr_AllChars));
         Result := StrToIntDef(GetNumbers(S), 1);
         Case I of
           1: Result := Result * 1000;
           2: Result := Result * 1000000;
         end;
         Exit;
       end;
    end;
    CoinAmountEx http://www.villavu.com/forum/showthread.php?t=48320

  13. #13
    Join Date
    Sep 2008
    Location
    Nova Scotia, Canada
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you so much. That was the answer I was looking for right from the start. A simple answer to what (I thought) was a simple question.

    Information sharing is not a disease people!

    Reminds me of when I was taking programming back in college: One of our first assignments was to write a network Battleship game in assembler! Talk about throwing people in over their heads.

    I actually managed to get that working somehow. And because I shared the knowledge gained from hours of pouring over manuals and trying things out everyone else got theirs at least partway working - enough that nobody flunked that assignment.

    Sorry for the attitude, but I work with someone who has the same attitude: They are deathly afraid of sharing any knowledge what-so-ever, and as a consequence everyone suffers. Oddly enough they get absolutely zero sympathy from the other techs when they whine that they have been unable to take a peaceful vacation in years, because nobody else knows how the system they work on works.
    http://www.stats.srl-forums.com/sigs/6137.png

    If I see you autoing with level 3/default clothes/crap name I WILL report you. Auto Correctly. - Put this in your sig.

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
  •