Results 1 to 9 of 9

Thread: GetAmount help

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default GetAmount help

    SCAR Code:
    {*******************************************************************************
    function GetAmount(ItemX, ItemY: Integer): Integer;
    By: ZephyrsFury
    Description: Returns the amount of an item at coordinates (ItemX, ItemY).
      Returns approximate values for 'K' and 'M'.
    *******************************************************************************}

    So is are the co-cords the center of the item, or what?
    i keep getting out of range errors and the function doesn't seem to find the amount text :-\

  2. #2
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    How are you using the function in your script?

  3. #3
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    i used it like this:
    SCAR Code:
    B:= InvBox(i);
     TIA[i]:= GetAmount(B.x1, B.y1);

    but i got it work when i changed the function to do like
    SCAR Code:
    Arrows:= ItemCoordinates('inv', 'dtm', DTMArrows, []);
     hi:= High(Arrows);
     for i:= 0 to hi do
      TIA[i]:= GetAmount(Arrows[i].x, Arrows[i].y);

    No problem anymore, but still im curios of how to select the x and y in GetAmount(x, y)

  4. #4
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Lemme guess, your code used to look something like this:
    SCAR Code:
    for i := 0 to 27 do
    begin
      B:= InvBox(i);
      TIA[i]:= GetAmount(B.x1, B.y1);
    end;

    If so, that would be the problem. You tried to find Item slot 0, which doesn't exist. You'd have to start the loop at 1.

  5. #5
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    1 to 28 i had, and it said the out of range was in Amount.scar (line 120 i think)

  6. #6
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Theoretically GetAmount is supposed to take any coordinate on or near the item and return an amount. However in practice it works best if you choose a coord close to the centre. The closer you get to the edges (and other items) the more likely the function will fail or get the wrong amount.

  7. #7
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    1 to 28 i had, and it said the out of range was in Amount.scar (line 120 i think)
    One last check. Did you set a size for the TIA array?

  8. #8
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    yes i did ^^
    TIA: array [1..28] of integer;

  9. #9
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    That's odd, because this code worked fine for me:
    SCAR Code:
    program New;
    {.include srl/srl.scar}
    var
    i : Integer;
    B : TBox;
    TIA : Array [1..28] of Integer;
    begin
    for i := 1 to 28 do
    begin
      B:= InvBox(i);
      TIA[i]:= GetAmount(B.x1, B.y1);
    end;
    end.

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
  •