Results 1 to 8 of 8

Thread: Counting items in inventory?

  1. #1
    Join Date
    Feb 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Counting items in inventory?

    I'm having a little problem with counting my items.
    I'm trying to count them, but I always come up with 0.
    I'm very sure I have inventory items.
    I tried more advanced methods, but even CountItemsArea('inv') does not work for me.
    Am I doing something horribly wrong?

    WriteLn(IntToStr(CountItemsArea('inv')));

    ^prints 0 when I have 15 assorted items in my inventory

  2. #2
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    If you just want to count the total amount of items to:

    SCAR Code:
    function CountInv: integer;

    var
      i : integer;

    begin
      for i := 1 to 28 do
        if ExistsItem(i) then Inc(Result);
    end;

    If you want to count a single item then you can use this dtm function, NOT made by me:

    SCAR Code:
    function ItemCoordsDtm(area: string; dtm: Integer): TPointArray;

    var

      startx, starty, rowsize, colsize, colnumber, rownumber, col, row: Integer;
      x1, y1, x2, y2: Integer;
      itemx, itemy: Integer;
      i: Integer;

    begin
      SetArrayLength(Result, 0);
      if (CheckArea(area)) then
      begin
        AreaInfo(area, startx, starty, rowsize, colsize, colnumber, rownumber);
        for row := 0 to rownumber - 1 do
          for col := 0 to colnumber - 1 do
          begin
            x1 := startx + col * colsize;
            y1 := starty + row * rowsize;
            x2 := x1 + colsize;
            y2 := y1 + rowsize;
            if (FindDTM(dtm, itemx, itemy, x1, y1, x2, y2)) then
            begin
              i := GetArrayLength(Result);
              SetArrayLength(Result, i + 1);
              Result[i]:= Point(x1, y1);
            end;
          end;
      end;
    end;

    function CountItemsDtm(area: string; dtm: Integer): Integer;

    var

      coords: TPointArray;

    begin
      coords := ItemCoordsDtm(area, dtm);
      Result := GetArrayLength(coords);
    end;

    Hope I helped .

    Nava2
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  3. #3
    Join Date
    Feb 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you so much! You answered my question perfectly. And do the Amount.scar inludes for counting not work?

  4. #4
    Join Date
    Feb 2007
    Location
    Estonia.
    Posts
    1,938
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by yargo View Post
    Thank you so much! You answered my question perfectly. And do the Amount.scar inludes for counting not work?
    Check it out by yourself maybe ?
    ~Eerik~

  5. #5
    Join Date
    Feb 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yea, I think I did, but I wanted to make sure I'm not retarded.

  6. #6
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    There's

    function CountItems(identifier: Integer; identifiertype: string; tol: TIntegerArray): Integer;

    Its in Inventory.scar, works for bmp, mask, color & dtm. I use it all the time.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  7. #7
    Join Date
    Feb 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i'm probably just not using it right then thanks.

  8. #8
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Narcle View Post
    There's

    function CountItems(identifier: Integer; identifiertype: string; tol: TIntegerArray): Integer;

    Its in Inventory.scar, works for bmp, mask, color & dtm. I use it all the time.
    I'm lazy and use what I know works .

    Nava2
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. counting inventory items
    By poolikemax in forum OSR Help
    Replies: 11
    Last Post: 12-04-2008, 06:44 PM
  2. Counting Items
    By smithsps in forum OSR Help
    Replies: 8
    Last Post: 05-15-2008, 12:42 AM
  3. Items in inventory help
    By wtf i sp4nk in forum OSR Help
    Replies: 2
    Last Post: 05-20-2007, 09:58 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
  •