sudoinit6 Posted May 23, 2018 Posted May 23, 2018 I know how to inventory.getItem("Lobster").getId() But is there a way to get the id for an item you don't have?
Night Posted May 23, 2018 Posted May 23, 2018 Programatically getting the id from a string is a lot harder than vice versa but there are two main ways I can think of to do it. First is to scrape a site such as the one @Apaec linked, second is to loop the Item Definition cache until you find the string you're looking for (make sure to check that it's not noted or anything).
sudoinit6 Posted May 23, 2018 Author Posted May 23, 2018 1 minute ago, Apaec said: I believe there's a list here: http://www.itemdb.biz/ I am looking for a way for the bot to get the id without the item. The GE api requires the item id for buyItem(int itemId, java.lang.String searchTerm, int price, int quantity) Makes it difficult to buy an item if it does not have one, and the list of items I want to buy is long, so I am trying to loop it. 3 minutes ago, Night said: Programatically getting the id from a string is a lot harder than vice versa but there are two main ways I can think of to do it. First is to scrape a site such as the one @Apaec linked, second is to loop the Item Definition cache until you find the string you're looking for (make sure to check that it's not noted or anything). Thanks! I will look into that.
Night Posted May 23, 2018 Posted May 23, 2018 2 minutes ago, sudoinit6 said: I am looking for a way for the bot to get the id without the item. The GE api requires the item id for buyItem(int itemId, java.lang.String searchTerm, int price, int quantity) Makes it difficult to buy an item if it does not have one, and the list of items I want to buy is long, so I am trying to loop it. Thanks! I will look into that. A word to the wise, you don't need to iterate every item in the cache as approximately half are noted. Find the pattern and this will cut down the execution time by roughly 50%. 1
dreameo Posted May 23, 2018 Posted May 23, 2018 Here you can use this: https://pastebin.com/5TWTBqNh Usage would be: ItemData.get("Cannonball","ID") You can include another level of cache via map if you want but, the way it's now is fine. Other properties can also be retrieved, check inside the code. 1
sudoinit6 Posted May 24, 2018 Author Posted May 24, 2018 6 hours ago, dreameo said: Here you can use this: https://pastebin.com/5TWTBqNh Usage would be: ItemData.get("Cannonball","ID") You can include another level of cache via map if you want but, the way it's now is fine. Other properties can also be retrieved, check inside the code. You are a saint, thanks.
HeyImJamie Posted May 24, 2018 Posted May 24, 2018 15 hours ago, dreameo said: Here you can use this: https://pastebin.com/5TWTBqNh Usage would be: ItemData.get("Cannonball","ID") You can include another level of cache via map if you want but, the way it's now is fine. Other properties can also be retrieved, check inside the code. Stealing this Thanks scrubbo x
dreameo Posted May 24, 2018 Posted May 24, 2018 5 hours ago, HeyImJamie said: Stealing this Thanks scrubbo x Meh, at least you got the decency to say that your gonna use it. It's meant to be public anyhow.
HeyImJamie Posted May 24, 2018 Posted May 24, 2018 4 hours ago, dreameo said: Meh, at least you got the decency to say that your gonna use it. It's meant to be public anyhow. It's neat, I had a personal 'price grabber' already but it didn't use JSON, so if I had too many requests it'd struggle.
Lemons Posted May 24, 2018 Posted May 24, 2018 On 5/23/2018 at 3:05 PM, Night said: A word to the wise, you don't need to iterate every item in the cache as approximately half are noted. Find the pattern and this will cut down the execution time by roughly 50%. Word to the wise: http://wiki.c2.com/?PrematureOptimization 1
dreameo Posted May 25, 2018 Posted May 25, 2018 1 hour ago, Lemons said: Word to the wise: http://wiki.c2.com/?PrematureOptimization
Canidae Posted May 25, 2018 Posted May 25, 2018 Instead of caching every item ID you need to know, you could also use this snippet made by @Explv. https://osbot.org/forum/topic/102611-ge-data-get-price-etc-by-item-name-no-external-libraries-required/