Jump to content

Get item ID's and prices by name


The Undefeated

Recommended Posts

I made a snippet which will cache all item prices and ID's out of an array in a list at the start of the script.

If the price or ID isn't cached it will automatically add it.

 

Usage:

  Reveal hidden contents
Edited by The Undefeated
  • Like 1
Link to comment
Share on other sites

Looks good. Since you asked for improvements, you could change the data structures. I think the best solution would be a two HashMaps, one mapping Names to item IDs and one mapping item IDs to price. The performance increase would be negligible in practice but it's better in terms of time complexity for this use case.

Even if there are many values, it (almost) always takes the same amount of time to execute put(), contains() and get(). The put() method is roughly equivalent to add().

With an ArrayList, it always takes the same time for add(), but the time it takes to execute contains() is proportional to the number of items in the list. This means if the number of items is very large, then it can take very long time to search through the list.

  • Like 1
Link to comment
Share on other sites

  On 4/8/2017 at 3:43 PM, Polymorphism said:

Check out mine, it uses the Jagex website. I like your caching idea, but as a pricing api i dont think the caching is necessary, that should be on a script by script basis

 

 

Expand  

The prices of the RS Grand Exchange API are not always right. Take for example the price of a bow string (ID:1777) so wouldn't recommend that.

 

  On 4/8/2017 at 4:01 PM, Diclonius said:

Looks good. Since you asked for improvements, you could change the data structures. I think the best solution would be a two HashMaps, one mapping Names to item IDs and one mapping item IDs to price. The performance increase would be negligible in practice but it's better in terms of time complexity for this use case.

Even if there are many values, it (almost) always takes the same amount of time to execute put(), contains() and get(). The put() method is roughly equivalent to add().

With an ArrayList, it always takes the same time for add(), but the time it takes to execute contains() is proportional to the number of items in the list. This means if the number of items is very large, then it can take very long time to search through the list.

Expand  

I'll change that anytime soon.

 

Link to comment
Share on other sites

  On 4/8/2017 at 8:48 PM, Polymorphism said:

 

I've never seen one that wasn't right...

6SjjXqV.png  AbKAZKK.png

Expand  

OSBuddy price is way lower but their website is down 50% of the time.

I checked this afternoon, and people in chat can confirm, the API price of bow strings were 281 each.

 

Edited by The Undefeated
Link to comment
Share on other sites

  On 4/8/2017 at 4:01 PM, Diclonius said:

Looks good. Since you asked for improvements, you could change the data structures. I think the best solution would be a two HashMaps, one mapping Names to item IDs and one mapping item IDs to price. The performance increase would be negligible in practice but it's better in terms of time complexity for this use case.

Even if there are many values, it (almost) always takes the same amount of time to execute put(), contains() and get(). The put() method is roughly equivalent to add().

With an ArrayList, it always takes the same time for add(), but the time it takes to execute contains() is proportional to the number of items in the list. This means if the number of items is very large, then it can take very long time to search through the list.

Expand  

Yes definitely use map for this.

Link to comment
Share on other sites

  On 4/9/2017 at 12:25 PM, Polymorphism said:

 

OSBuddy price doesn't reflect in game prices i believe. Which is why i never use it

Expand  

But as I said, the official GE API fails many times. I used it in one my scripts and it's horrible to use because of the wrong prices sometimes. That's why I think using the wiki is the way to go.

 

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...