Thread Tools Display Modes
02-23-18, 11:33 PM   #1
Oren
A Defias Bandit
 
Oren's Avatar
Join Date: Feb 2018
Posts: 2
Pickup talent spells that are not learned

Hi everyone,

I've picked up an abandoned addon to try to update it for the last version of WoW and learn a bit of LUA development (I'm a web developer).

The addon is called ActionBarSaver, and it allows you to save spells positions in your bars (you can save profiles and restore them, they are saved by class). When I downloaded it, it worked for spells and objects (like 90% of what we need ^^), but not with mounts, pets, learned pve/pvp talents and unlearned pve/pvp talents.

For the first 3 I managed to make it work after finding the proper API methods, but I can't make the last one...
Basically, when you select a talent that gives you a spell, if you place it in your bars and learn another talent on the same line, the spell can't be used anymore but it stays in your bars (and I wanted to keep it, so that if you have to change your spec quickly the spell is already in your bars, no need to open your spellbook).

I can save the spellID, but when I want to restore it doesn't pickup the spell

Here is what I tried:

Lua Code:
  1. -- [...] Some code to go through each spell of each saved bar in the profile, and get its name and ID
  2.         -- spellCache = array containing all the class spells (spellCache[spellName] = spellID)
  3.         -- talentPvPCache = same for pvp talents
  4.         -- talentPvECache = same for pve talents
  5.         -- actionID = spellID
  6.  
  7.         if (spellCache[spellName]) then
  8.             PickupSpellBookItem(spellCache[spellName], BOOKTYPE_SPELL);
  9.         elseif (talentPvPCache[spellName]) then
  10.             PickupPvpTalent(talentPvPCache[spellName])
  11.         elseif (talentPvECache[spellName]) then
  12.             self:Print(spellName)
  13. --            PickupSpellBookItem(spellCache[spellName], BOOKTYPE_SPELL);
  14.         else
  15.             PickupSpell(actionID)
  16.         end

(at the moment I just print out the name, testing ^^)

To save a spell (when saving a profile), it gets the spellInfo and store it into a string that's later used to restore:

Lua Code:
  1. -- actionID = bar slot where the spell is displayed
  2. -- id = spellID
  3. -- actionType = "spell"
  4.  
  5. local name, spellRank = GetSpellInfo(id)
  6.  
  7. if (name and spellRank) then
  8.     set[actionID] = string.format("%s|%d|%s|%s|%s|%d", actionType, id, "", name, spellRank or "", "")
  9. end

What I do is first generate an array with all the spells names/IDs, and then go through my saved bar to get the spell, find it from my "cache", and pick it up to put it in the position it's supposed to be. But for unlearned talents, I tried "PickupSpell", "PickupSpellBookItem" (both with the spellID) and "PickupTalent" (tried with spellID and talentID) but nothing worked

Do you know if it's possible? And if so what am I doing wrong?
I looked through the "Pickup..." methods on WoW API on Gamepedia, but didn't find anything that could help.
  Reply With Quote
02-24-18, 06:16 AM   #2
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
I have a personal addon that saves bars and also replace macro tabs (general become char macros and char macros become general macros) my solution for this problem is sketched bellow:
Lua Code:
  1. --macros whose names are in the format PHxx where xx is between 00 and 99 are reserved for place holder macros
  2.  
  3. local ph_number = 0 --number of current place holder macros
  4. local ph_list = {} --list of place holder macros; k: spell id; v:macro name
  5. local Create_Place_Holder_Macro
  6.  
  7. --put this in the load loop of saved action bars, when you have a spell to this:
  8. --in my version of action bar saver there is no cache, so the code will need some adaptation on this regard
  9. PickupSpell(spell_id)
  10. if GetCursorInfo()==nil then
  11.     if ph_list[spell_id]==nil then
  12.         ph_number = ph_number+1
  13.         ph_list[spell_id] = Create_Place_Holder_Macro(spell_id,ph_number)
  14.     end
  15.     PickupMacro(ph_list[spell_id])
  16. end
  17.  
  18. --put this in the save loop of current action bars, when you have a macro to this to check if you have a place holder macro to save the spell:
  19. if macro_name:match("^PH%d%d$") then
  20.     for k,v in pairs(ph_list) do
  21.         if v==macro_name then
  22.             local actionType = "spell"
  23.             local id = k
  24.             local name, spellRank = GetSpellInfo(id)
  25.             set[actionID] = string.format("%s|%d|%s|%s|%s|%d", actionType, id, "", name, spellRank or "", "")
  26.             break
  27.         end
  28.     end
  29. end
  30.  
  31. function Create_Place_Holder_Macro(spell_id,ph_number)
  32.     local am = GetNumMacros()
  33.     local macro_name = "PH"..string_format("%02d",ph_number)
  34.     local spell_name,_,texture = GetSpellInfo(spell_id)
  35.     if texture then
  36.         if am<MAX_ACCOUNT_MACROS then
  37.             CreateMacro(macro_name,texture,"#showtooltip\n/cast "..spell_name)
  38.             return macro_name
  39.         end
  40.     end
  41. end
  42.  
  43. --you need a way to detect that specialization has changed and when it happens you should delete all place holder macros
  44. local function call_me_when_spec_changes()
  45.     if ph_number>0 then
  46.         for i=1,ph_number do
  47.             local macro_name = "PH"..string_format("%02d",i)
  48.             DeleteMacro(macro_name)
  49.         end
  50.         wipe(ph_list)
  51.         ph_number = 0
  52.     end
  53. end
The basic idea is to put a macro with /cast spell when the spell can't be picked up.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 02-24-18 at 02:45 PM.
  Reply With Quote
02-24-18, 09:02 AM   #3
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Pretty sure it's just a limitation of the way unlearned talents spells work. If you re-specced and specced back while having one such spell on your bars I'm pretty sure it would remove itself. I want to try that now if I can confirm it.
Edit: I was wrong. I'm pretty sure there was something that acted that way but I really can't remember what it was. Probably not related to talents, anyway.

Though, don't they have placeholder spells for talent rows, which automatically change into the selected talent? I might need to look into that, not sure if they exist for PvP talents though. Actually I'm not sure how PvP talents behave when outside of PvP areas, since the game unlearns them on leaving and re-learns them on entering (as opposed to simply disabling/enabling their use >.> gotta love spaghetti)

Like 175686 Stopping Power, for Hunters. Placeholder for Lv. 60 talents, there should be a spell like this for all classes and all active talent rows, might need to bring up a list. Not sure how one would detect that the unlearned spell is an unlearned talent, I guess if you can still read spell name then you could compare with class and have a table of talent spell names for that class or something, and instead save that placeholder spell.

Might have some unwanted side-effects though, I guess. If they wanted different spells on their talent row to be on different action bar slots. This would effectively be putting all of them on the same slot with no way to undo it unless the user manually removed it (or maybe place duplicates of the spell on different action bar slots.)

Edit: Apparently those placeholder spells don't exist if even just one talent in the row is passive. That's lame. I guess this isn't a solution, then.

Banknorris' idea seems clever enough to work with minimal side-effects, though one limitation I can think of is that it wouldn't work if the player has already used all their macro slots.

Last edited by Ammako : 02-24-18 at 09:48 AM.
  Reply With Quote
02-24-18, 09:53 AM   #4
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
@Oren: You should be aware that it is not "LUA" but rather "Lua" as it is the Portuguese word for "moon", not an acronym.

I am sorry, but, that just drives me up the wall.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!

Last edited by jeffy162 : 02-24-18 at 09:56 AM. Reason: more blah blah blah.
  Reply With Quote
02-25-18, 12:14 AM   #5
Oren
A Defias Bandit
 
Oren's Avatar
Join Date: Feb 2018
Posts: 2
@jeffy162: You're right, I will try to remember that

@Banknorris: Thanks! That's a good workaround actually, doesn't solve entirely the problem since, like @Ammako said, some people might have used all of their general macro slots (not me, so I'll try doing that ^^).

@Ammako: So I just did the test on my DK: row 3 of honor talents contains 2 spells (Dark Simulacrum & Anti-Magic zone), I put the 2 of them in a bar with Frost spec, outside of a battleground (both spells disabled, one of them having the mention "Honor Talent" in its tooltip). I switch to Unholy spec (I even tried to reload UI and logout), go back to frost spec and the spells are still there, same if I try with PvE talents!

So the games allows that, but maybe there's no way to do it through the API I'll still try to find the proper solution while using @Banknorris workaround for the time being ^^ but if anyone has an idea, please tell!

Last edited by Oren : 02-25-18 at 12:16 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Pickup talent spells that are not learned

Thread Tools
Display Modes

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