Results 1 to 16 of 16

Thread: GetBankItemAmount

  1. #1
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default GetBankItemAmount

    Simba Code:
    {*******************************************************************************
    function GetBankIndexItemAmount(const Index: Integer): Integer;
    By: Daniel (Mayazcherquoi)
    Description: Returns the amount of an item in the bank at bank index, Index.
    *******************************************************************************}

    function GetBankIndexItemAmount(const Index: Integer): Integer;
    begin
      Result := getAmountBox(BankIndexToMSBox(Index));
    end;

    {*******************************************************************************
    function GetBankItemAmount(const x, y: Integer): Integer;
    By: Daniel (Mayazcherquoi)
    Description: Returns the amount of an item in the bank at bank screen
      coordinates (Row, Col).
    *******************************************************************************}

    function GetBankItemAmount(const Row, Col: Integer): Integer;
    begin
      Result := GetBankIndexItemAmount(BankPointToBankIndex(Point(Row, Col)));
    end;

    {*******************************************************************************
    function GetMSBankItemAmount(const x, y: Integer): Integer;
    By: Daniel (Mayazcherquoi)
    Description: Returns the amount of an item in the bank at main screen
      coordinates x, y.
    *******************************************************************************}

    function GetMSBankItemAmount(const x, y: Integer): Integer;
    begin
      Result := GetBankIndexItemAmount(BankPointToBankIndex(MSTPointToBankPoint(Point(x, y))));
    end;

    Self-explanatory, DemiseScythe needed this and there was one for the inventory (getAmount), so I decided to make this. Can be very useful.

    Add to core/Bank.scar.

    EDIT: It works, btw

    Regards,
    Daniel.
    Last edited by Daniel; 12-25-2011 at 11:18 AM.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  2. #2
    Join Date
    Dec 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i used it but the getbankitemamount returned to zero all the time. could you help me figure out what's wrong? I was doing fletching, and wanted to know the amount of materials left by finding whichever material (unstrung bow or bow string) are fewer in the bank.

    Simba Code:
    function GetBankIndexItemAmount(const Index: Integer): Integer;
    begin
      Result := getAmountBox(BankIndexToMSBox(Index));
    end;

    function bankamount(const x, y: Integer): Integer;
    begin
      Result := GetBankIndexItemAmount(BankPointToBankIndex(Point(x,y)));
    end;

    inside the main loop I have this:

    Simba Code:
    if (bankamount(col1,row1)<bankamount(col2,row2)) then
         amount:=bankamount(col1,row1)
        else
         amount:=bankamount(col2,row2);

    when it didn't work I added a writeln to know the bankamount(col1,row1), but it was zero.
    Last edited by darklordnd; 12-24-2011 at 09:34 PM.

  3. #3
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by darklordnd View Post
    i used it but the getbankitemamount returned to zero all the time. could you help me figure out what's wrong? I was doing fletching, and wanted to know the amount of materials left by finding whichever material (unstrung bow or bow string) are fewer in the bank.

    Simba Code:
    function GetBankIndexItemAmount(const Index: Integer): Integer;
    begin
    Result := getAmountBox(BankIndexToMSBox(Index));
    end;

    function bankamount(const x, y: Integer): Integer;
    begin
    Result := GetBankIndexItemAmount(BankPointToBankIndex(Point( x,y)));
    end;


    inside the main loop I have this:

    Simba Code:
    if (bankamount(col1,row1)<bankamount(col2,row2)) then
    amount:=bankamount(col1,row1)
    else
    amount:=bankamount(col2,row2);


    when it didn't work I added a writeln to know the bankamount(col1,row1), but it was zero.
    It doesn't go by columns. It goes either by the main screen coordinates or the bank screen coordinates. I might create one for column's/rows if SRL offers the conversion methods. I will do that soon though.

    In order to use it, just find the DTM of your item in the bank, and use GetMSBankItemAmount to return the value.


    EDIT: My mistake, Bank Point is expressed in row's and column's.

    To fix your issue, switch your column variable and row variable around. It's in the format (Row, Col), not (Col, Row) [Which is what you were doing].
    Last edited by Daniel; 12-25-2011 at 07:09 AM.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  4. #4
    Join Date
    Feb 2009
    Location
    inside Hello World! Application
    Posts
    232
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Cool thanks needed very much ^^ theres also one for Pouch somewhere right? hmm

  5. #5
    Join Date
    Dec 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    are you sure it's row - col and not col - row? I think everything on pascal are x - y, which are col number - row number.
    Anyway, I tried swapping those around and the result is still the same - just zero. I think the problem is not there, because even when I mistake row for col, the result should be something else (amount of a different slot) and not zero. Please help me, I'm a noob

  6. #6
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by darklordnd View Post
    are you sure it's row - col and not col - row? I think everything on pascal are x - y, which are col number - row number.
    Anyway, I tried swapping those around and the result is still the same - just zero. I think the problem is not there, because even when I mistake row for col, the result should be something else (amount of a different slot) and not zero. Please help me, I'm a noob
    It wouldn't just be pascal, it's general mathematics. I apologise for the misnaming of my initial parameters (as I had thought those coordinates were relative bank screen coordinates). Please refer to the latest update (thread edit) for a revised version reflecting the parameter name changes.

    P.S: Don't forget, row's and columns start at 0, 0 (NOT 1, 1!).
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  7. #7
    Join Date
    Dec 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    Please refer to the latest update (thread edit) for a revised version reflecting the parameter name changes.
    sorry, but I don't understand what you're saying. where is the thread you talked about? could you make it clear for me as what to do? thank you very much.

  8. #8
    Join Date
    Dec 2011
    Location
    Texas
    Posts
    348
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice this could be a substitute for DTM's

  9. #9
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Looks good to me.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  10. #10
    Join Date
    Dec 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yeah, i'd say this is what I really want simba to include in the library. but anyone help me with the problem yet...

  11. #11
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by darklordnd View Post
    sorry, but I don't understand what you're saying. where is the thread you talked about? could you make it clear for me as what to do? thank you very much.
    A forum is divided into categories and sub-forums. Within each sub-forum are threads (a.k.a topics) which initiate different areas/aspects of conversation. By "the thread", I was referring to this thread, that is, the original (first) post of this thread.

    In my first post, you will notice that I had edited the code within [simba][/simba] tags, specifically the second function. I had replaced the parameters (values) x and y, to Row and Col, which is more appropriate and prevents further confusion.

    Now you will see that instead of x and y, it is Row and Col. So, please use that format to find your item's amount in the bank. And don't forget, the first slot in the bank is 0, 0 (that is, row 0 and column 0).

    If you are having any more troubles, please let me know.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  12. #12
    Join Date
    Dec 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    as I say, I tried swapping those, but the result is still zero. If it's a mistake of row and col, it should return some other value instead. So I still can't find out why my script doesn't work.

  13. #13
    Join Date
    Dec 2011
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    anyone come up with a solution to help me yet?

  14. #14
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by darklordnd View Post
    anyone come up with a solution to help me yet?
    Have you tried initially finding the object in the bank via a DTM and parsing those coordinates to the other function?

    It could be a problem in converting a bank point into a main screen point now that tabbing exists. :-/

    EDIT: If you don't want to do the above, switch to the tab (not the main one) where the item you are searching for exists.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  15. #15
    Join Date
    Nov 2011
    Posts
    1,268
    Mentioned
    17 Post(s)
    Quoted
    217 Post(s)

    Default

    Quote Originally Posted by Jhangir View Post
    Nice this could be a substitute for DTM's
    You still need to find the coordinates of the item. I totally love this method and it is key on one of my most precious scripts.

    Thank you Daniel for developing this and it works great ^.^

    This does not replace DTMs, you need to use Item finding method to get x and y of the item, then do something like this

    Integer := GetMSBankItemAmount(x, y);

    and it should work. That above is how to correctly set up this method in case anyone is wondering =)
    GLH Tutorial ~ OpenGL Scripting
    http://villavu.com/forum/showthread.php?p=1292150

    GLH Scripts ~ Abyssal Scripts
    http://villavu.com/forum/showthread.php?p=1293187
    Current Projects:
    A) DemiseSlayer Pro (Released/100%).
    B) Demise Power Miner(Released/100%).
    C) Demise Pyramid Plunder(Planning Stage/0%).

  16. #16
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Added to my commit list. Will edit when committed.

    E: Committed to SRL5. Will push later tonight.
    Last edited by Coh3n; 01-04-2012 at 05:46 AM.

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
  •