Results 1 to 8 of 8

Thread: Counting items

  1. #1
    Join Date
    Mar 2012
    Location
    Alberta
    Posts
    52
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Counting items

    How do you count stack-able items in your inventory? Like for me I want to count water runes in inventory.

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    ItemAmount function.

    From the SRL include:


    Simba Code:
    (*
    ItemAmount
    ~~~~~~~~~~

    .. code-block:: pascal

        function ItemAmount(area, ItemType: string; Item: Integer; Tol: TIntegerArray): Integer;

    Counts the number of items found within the Area (counts stacks).
    Parameters are exactly the same as ItemCoordinates.

    .. note::

        Author: masquerader
        Last Modified: Unknown by ZephyrsFury

    Example:

    .. code-block:: pascal

      var
        itemsFound: integer;
      begin
          itemsFound := ItemAmount('inv', 'dtm', dtm_Ore, []);
        writeln('Ore found: '+toStr(itemsFound));
      end;
    *)

    function ItemAmount(area, ItemType: string; Item: Integer; Tol: TIntegerArray): Integer;
    var
      startX, startY, rowSize, colSize, colNumber, rowNumber: integer;
      Coords: TPointArray;
      i, h: Integer;
    begin
      Result := 0;
      AreaInfo(area, startX, startY, rowSize, colSize, colNumber, rowNumber);
      Coords := ItemCoordinates(Area, ItemType, Item, Tol);
      h := High(Coords);
      for i := 0 to h do
        Result := Result + GetAmountBox(IntToBox(Coords[i].x - floor(rowSize / 2),
                                                 Coords[i].y - floor(colSize / 2),
                                                 Coords[i].x + floor(rowSize / 2),
                                                 Coords[i].y + floor(colSize / 4)));
    end;
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Mar 2012
    Location
    Alberta
    Posts
    52
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ah thanks I was trying to use CountItem but I see why it wasn't working

  4. #4
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    function GetAmountBox(box: TBox): integer;

    Ex.

    Simba Code:
    {$i srl/srl.simba}
    var
      amount : Integer;
      b: TBox;
    begin
      SetupSRL;
      b := InvBox(1); // creates a box from the first inventory slot.
      amount := GetAmountBox(b); // counts the text in that first slot ^
      writeln(amount);
    end.

    edit: 'd

  5. #5
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    What about items in the bank?

  6. #6
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    What about items in the bank?
    Here's what I used in my fletcher (prob outdated section now)

    Simba Code:
    procedure CountItemCheck;
    var
      count: Integer;
      b: TBox;
    begin
      if (bankscreen) then
      begin
        b := BankIndexToMSBox(BankPointToBankIndex(Point(9, 0)));
        count := GetAmountBox(b);

        Writeln('Items Remaining = ' + IntToStr(count) + '.');

        if (count < 100) then
        begin
          Writeln('Almost out of supplies! -> CIAO / TERMINATING SCRIPT');
          TerminateScript;
        end;
      end;
    end;

    ^ Just more boxes. Could use a DTM/count colors/etc. (ex. to find the item in bank) to pass parameters for it too, the one I have above is static

  7. #7
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Ah, I see, thanks

  8. #8
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    What about items in the bank?
    Or, simpler, getting the number of items out of a TP:

    Simba Code:
    GetBankItemAmount(((TP.x - 38) div 44), ((TP.y - 90) div 45)) < 50)

    Same function can be used if you know the coordinates too (like 0, 0). The formulas I'm using are to transform a TP into a bank row and column.

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
  •