Results 1 to 5 of 5

Thread: Counting items

  1. #1
    Join Date
    Mar 2011
    Location
    Somerset, UK
    Posts
    304
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default Counting items

    Simba Code:
    Procedure countinv;
      var
      i: Integer;
      myBox: TBox;

      begin
        ItemCount:= 0;
        Snapegr := BitmapFromString(24, 23, 'meJyFlDEKAkEUQ8Va8Ap7BGEbLc' +
              'TCQryCl/D+nR8CISZ/ZuAXs7szj/z8zO6P1y51PBzu3zOq1lXXzwm' +
              'l77ftUrX/n20h2N9CUCOIcUhQjqmtI7fney6mLe6ZqDIxuW7VGgpW' +
              'pAA2hSNty0BxKCl+5IwSODsbh4nRwSmE/jAAeFT3uB9rfZmhoj8GM' +
              'Tds7uaMoixyJsy6TgJb05YNYvCEgKD+6Fl8sljqceuoIl2lpwBRbB' +
              'tptZqohLQByJhZBji1tp1UouFRMq8G7Vre1kRV2W2tTjNpS5F2W+E' +
              '8tCUqH230k9/aKIeKmhCW/xOzfQkZdWTwCWrubf49fgFjIpI=');
        for i := 1 to 28 do
          begin
            myBox := InvBox(i);
            if CountItemsIn('inv', 'Bitmap', Snapegr, [5]);
            inc(ItemCount);
            SnP:= ItemCount;
           End;
    end;

    Any ideas why it only counts one in my inventory all the time
    its called everytime i pick up a Snape but it just says 1

  2. #2
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Simba Code:
    function CountSnapes: Integer;
    var
      BMP: Integer;
    begin
      BMP := BitmapFromString(0, 0, '');
      Result := CountItems('dtm', BMP, [12]); //BMP tolerance goes in bracket
      FreeBitmap(BMP);
    end;

  3. #3
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Also remember this
    Simba Code:
    if FindDTM() then
    begin
      Inc(ItemCount);
    // whatever else you want to do
    end else
     Writeln('FindDTM Failed');

    Because the way you have it in the first post it finds the DTM and does the counting all in one block does that make sense? I know what i mean but re-reading it, it sounds really confusing

    Also is myBox ever used?

    I will edit this so it makes more sense when I get home



  4. #4
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Did you read the BMP tutorial I gave you on the other thread...
    Anyway:
    Simba Code:
    function CountInv: Integer;
    var
      Snapegr: Integer;
    begin
      Snapegr := BitmapFromString(24, 23, 'meJyFlDEKAkEUQ8Va8Ap7BGEbLc' +
              'TCQryCl/D+nR8CISZ/ZuAXs7szj/z8zO6P1y51PBzu3zOq1lXXzwm' +
              'l77ftUrX/n20h2N9CUCOIcUhQjqmtI7fney6mLe6ZqDIxuW7VGgpW' +
              'pAA2hSNty0BxKCl+5IwSODsbh4nRwSmE/jAAeFT3uB9rfZmhoj8GM' +
              'Tds7uaMoixyJsy6TgJb05YNYvCEgKD+6Fl8sljqceuoIl2lpwBRbB' +
              'tptZqohLQByJhZBji1tp1UouFRMq8G7Vre1kRV2W2tTjNpS5F2W+E' +
              '8tCUqH230k9/aKIeKmhCW/xOzfQkZdWTwCWrubf49fgFjIpI=');
      Result := CountItemsIn('inv', 'Bitmap', Snapegr, [5]);
    end;

    Standards & function fixed. Please don't capitalize one bold and then leave the other lowercase Just make all bold worlds lowercase and use 2 spaces for indentation.
    Ce ne sont que des gueux


  5. #5
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    Don't forget to free the bitmap at the end of the function! Freebitmap(snapegrass)
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

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
  •