Jump to content

How to efficiently calculate the inventorys gp value?


roguehippo

Recommended Posts

http://osbot.org/forum/topic/102611-ge-data-get-price-etc-by-item-name-no-external-libraries-required/

 

 

private long getInventoryValue() {

      long value = 0;

     for(Item i: inventory.getAll()) {

           value += new ExchangeItem(i.getName(), i.getId()).getPrice();

      }

      return value;

}

       

Edited by Imateamcape
Link to comment
Share on other sites

http://osbot.org/forum/topic/102611-ge-data-get-price-etc-by-item-name-no-external-libraries-required/

 

 

private long getInventoryValue() {

      long value = 0;

     for(Item i: inventory.getAll()) {

           value += new ExchangeItem(i.getName(), i.getId()).getPrice();

      }

      return value;

}

 

While you did provide the skeleton for doing this, it's important to note that you should cache the item value or something.

 

Firstly, it's not like the item's price will change that much over the course of the script running. Secondly and most importantly, you don't want to be bombarding their server with requests as well as stopping the thread from running until the page has loaded. Of course using asynch methods would be better for this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...