Thread Tools Display Modes
04-10-13, 09:38 AM   #1
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Looking for the right API's on Spells, please help :)

Greetings,

I'm working on an AddOn, abit like BagBuddy if anyone knows of it. Maybe its way harder to do something like this, than i thought... anyways...

Now what i want my AddOn to do is the following:

Create a frame using the default layout of the spellBook, and consists of 27 buttons.

Here is how it looks like atm:



Now what i want to do is the following:

For each Button in the frame, add a spell to it, sorted by name automatically.. A nextpage and prevpage button will ofc come to store all spells.

However, to get the informations from Bags is pretty easy - GetNumBagSlots() and NUM_BAG_SLOTS.

How do i return the number of spells available?

Hope you understand what i'm trying to accomplish.
  Reply With Quote
04-10-13, 10:07 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
BagBuddy, for those who do not know, comes from Cladhaire's book World of Warcraft Programming, Second Edition, by James Whitehead II and Rick Roe. Download link to the complete zip --> http://wowprogramming.com/chapters/second-edition/09

As for your specific problem, sorry, can't help you, but I will tell you that once you fill in the spell names, even if you put them alphabetically based on English, they will not be alphabetical in other languages. At least not without some really fancy coding.
  Reply With Quote
04-10-13, 10:13 AM   #3
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by myrroddin View Post
BagBuddy, for those who do not know, comes from Cladhaire's book World of Warcraft Programming, Second Edition, by James Whitehead II and Rick Roe. Download link to the complete zip --> http://wowprogramming.com/chapters/second-edition/09

As for your specific problem, sorry, can't help you, but I will tell you that once you fill in the spell names, even if you put them alphabetically based on English, they will not be alphabetical in other languages. At least not without some really fancy coding.
Localization won't help here?
  Reply With Quote
04-10-13, 10:20 AM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
That's the problem with localization: Google's translate software isn't perfect, but to give you an idea, go to translate.google.com, put in the word Resurrection into the first side, and change the language you want to German.

"Resurrection" == "Auferstehung". The German spells in your AddOn would be in a different order because of localization.
  Reply With Quote
04-10-13, 10:31 AM   #5
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by myrroddin View Post
That's the problem with localization: Google's translate software isn't perfect, but to give you an idea, go to translate.google.com, put in the word Resurrection into the first side, and change the language you want to German.

"Resurrection" == "Auferstehung". The German spells in your AddOn would be in a different order because of localization.
Hmm, yeah.. but how about this:

enUS
SPELLMATE_TABLE = {
SPELLMATE_RESURRECTION = "Resurrection"
}

deDE
SPELLMATE_TABLE = {
SPELLMATE_RESSURECTION = "Auferstehung"
}

and when i want to retreive the name info instead of putting the w/e ID in there call the Table from the localization instead? Blizzard has listed all the correct names for each spell, item etc..


i'm new at this, so i have no idea if it could work in any way.
  Reply With Quote
04-10-13, 10:36 AM   #6
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Have you looked at GetSpellBookItemInfo()?

For localization, why not just use GetSpellInfo?
  Reply With Quote
04-10-13, 10:57 AM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by myrroddin View Post
BagBuddy, for those who do not know, comes from Cladhaire's book World of Warcraft Programming, Second Edition, by James Whitehead II and Rick Roe. Download link to the complete zip --> http://wowprogramming.com/chapters/second-edition/09

As for your specific problem, sorry, can't help you, but I will tell you that once you fill in the spell names, even if you put them alphabetically based on English, they will not be alphabetical in other languages. At least not without some really fancy coding.
If you use the GetSpellLink(SpellID) then it gonna return the spells name client localized, then you can convert this to string and then put into a table and then sort it.
  Reply With Quote
04-10-13, 10:59 AM   #8
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
One assumes you are going to get a list of all the spells with which you are going to populate your frame. And that list should really contain the spellId of each of the spells. You can then go through the list to determine the localized name of each spell using GetSpellInfo(spellId). Then you can sort the list based on their localized spell name. [Basically you should rely on the API Blizzard provides to give you the localized spell names as this will be correct within the context of the game.]

The question is how are you going to obtain your list of spellIds for your frame?

If you are trying to get the spells the user already has in the spell book you can use GetNumSpellTabs() to get the number of tabs the player has, GetSpellTabInfo() to get the number of spells on a tab, GetSpellBookItemName() using BOOKTYPE_SPELL as the second parameter to get the spell name, and GetSpellBookItemInfo() for the spellId. Basically you will be looping through each of the tabs pulling spell information and adding it to your list. I have not checked, but assume you can use the name returned from GetSpellBookItemName() as the localized name instead of having to get it with the spellId as detailed above. But of course this only works if you are using this technique to create your list of spellIds.

Of course if you have a list of spellIds in another manner, you should be fine with localizing as above.
  Reply With Quote
04-10-13, 11:16 AM   #9
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by Nimhfree View Post
One assumes you are going to get a list of all the spells with which you are going to populate your frame. And that list should really contain the spellId of each of the spells. You can then go through the list to determine the localized name of each spell using GetSpellInfo(spellId). Then you can sort the list based on their localized spell name. [Basically you should rely on the API Blizzard provides to give you the localized spell names as this will be correct within the context of the game.]

The question is how are you going to obtain your list of spellIds for your frame?

If you are trying to get the spells the user already has in the spell book you can use GetNumSpellTabs() to get the number of tabs the player has, GetSpellTabInfo() to get the number of spells on a tab, GetSpellBookItemName() using BOOKTYPE_SPELL as the second parameter to get the spell name, and GetSpellBookItemInfo() for the spellId. Basically you will be looping through each of the tabs pulling spell information and adding it to your list. I have not checked, but assume you can use the name returned from GetSpellBookItemName() as the localized name instead of having to get it with the spellId as detailed above. But of course this only works if you are using this technique to create your list of spellIds.

Of course if you have a list of spellIds in another manner, you should be fine with localizing as above.
Thank you! Was worth the read, imma try to accomplish this somehow.
  Reply With Quote
04-10-13, 06:32 PM   #10
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Resike View Post
If you use the GetSpellLink(SpellID) then it gonna return the spells name client localized, then you can convert this to string and then put into a table and then sort it.
I thought about this right after I went to bed

The relevant pages in the book are 88-90.
  Reply With Quote
04-11-13, 06:17 AM   #11
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Got it working now, now i just need to add a Dropdown Menu to select in which order i would like to sort the stored data.

Name
Level
Type

<-- The name sort is working just fine and is the default state. Imma go look up some dropdown menu templates and hopefully i can add sort function to level and type.

Level - The level the spell is available
Type - Wether its Arcane, Frost, Fire, etc.

If anyone got some smart ideas to implement this, feel free to bring up some examples
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Looking for the right API's on Spells, please help :)


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