Thread Tools Display Modes
01-22-14, 10:33 AM   #1
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
API for Item Info

I've been looking at addons like Buffet from Tekub and notice that a table (for lack of the proper Lua term) of food and drink buff items is used. I have been reading the API (and trying to stay awake) for GetContainerItemxxx (I am tinkering with a script that loop through your bags) to see if you can just look the information up dynamically instead of hard coding it.

Perhaps Blizzard does not allow access to this information via the API or I am looking in the wrong place. I'm new to Lua, but not programing and I prefer to do look ups for what I have available instead of having to manually update information when there are changes or additions.

Thoughts? Is it possible? Or is this the only way to write these type of addons?

Thanks,

Roc
  Reply With Quote
01-22-14, 10:37 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I don't understand. What do you want to do, exactly?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
01-22-14, 10:41 AM   #3
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by Lombra View Post
I don't understand. What do you want to do, exactly?
So, with Buffett, it finds the best food/water in your bags, but it has the data (itemID and value of the food) in the .lua file. I'm trying to see if the value of the food/water can be looked via the API instead of hard coding it in the code.

I hope this helps clarify things. English is my first and second language.
  Reply With Quote
01-22-14, 10:43 AM   #4
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
So you want to find out what category an item is, e.g. herb, ore, food, weapon?

You can use GetContainerItemID to get the item's itemID and then the regular GetItemInfo function to get its category (among other things).

You'll want to look at the itemType and itemSubType returns of GetItemInfo.

Edit: I posted this before I saw your reply to Lombra, see my post below.

Last edited by Choonstertwo : 01-22-14 at 10:47 AM. Reason: Posted too soon.
  Reply With Quote
01-22-14, 10:46 AM   #5
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Originally Posted by rocnroll View Post
So, with Buffett, it finds the best food/water in your bags, but it has the data (itemID and value of the food) in the .lua file. I'm trying to see if the value of the food/water can be looked via the API instead of hard coding it in the code.

I hope this helps clarify things. English is my first and second language.
The only way I know of to get the amount HP/Mana restored by food/drink is to scan the tooltip.

Ro posted an example of tooltip scanning here a while ago.

Last edited by Choonstertwo : 01-22-14 at 10:52 AM. Reason: Added link.
  Reply With Quote
01-22-14, 11:08 AM   #6
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by Choonstertwo View Post
The only way I know of to get the amount HP/Mana restored by food/drink is to scan the tooltip.

Ro posted an example of tooltip scanning here a while ago.
Thank you, that does what I was looking for (.99%). It looks like I will have to parse the text to grab the value I want. I'll post my code when done, perhaps it will make sense then.
  Reply With Quote
01-22-14, 08:29 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The problem with using tooltip scanning is that either you need to hardcode the search patterns for every language, or you're screwing over non-English players. In cases like this where the set of items you're working with is fairly limited, and the values you're using change rarely, if ever, it really is easier to just set up a static data table like you see in Buffet.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-22-14, 09:19 PM   #8
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by Phanx View Post
The problem with using tooltip scanning is that either you need to hardcode the search patterns for every language, or you're screwing over non-English players. In cases like this where the set of items you're working with is fairly limited, and the values you're using change rarely, if ever, it really is easier to just set up a static data table like you see in Buffet.
You raise a good point. I applied conventional programming techniques ignoring the language situation and as you said, a limited number of items. I will still work on it as a learning project.
  Reply With Quote
01-23-14, 12:35 AM   #9
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
It's a good way to build the table, if nothing else: Save your scans to SavedVariables, for spells which do not already exist in the table.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » API for Item Info


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off