11-20-20, 05:48 PM | #1 |
Hook into a MountJournal function ?
Hello everyone,
I'm currently trying add an extra option to the right click context menu in the mount collection. After some digging in wowpedia and the Blizzard_MountCollection.lua i think i need to hook into MountOptionsMenu_Init and add my button via UIDropDownMenu_AddButton, but thats where i'm stumped. Hooking into the C_MountJournal functions works just fine like so: Lua Code:
but hooking into MountOptionsMenu_Init not ... Lua Code:
I also tried to hook into the ADDON_LOADED event and from there hook into MountJournal because at this point it shouldn't be nil, but to no avail. for code see here: https://pastebin.com/pXth1U6a any tips ? is there an other way i haven't tried ? is this even possible ? thx for your help greetings Draugor |
|
11-20-20, 08:53 PM | #2 |
If you mark you addons .toc to load when the Collections addon is loaded, you don't have to worry about tracking ADDON_LOADED (assuming that's the only addon you're waiting for and your addon isn't doing anything before the collections load, I didn't look).
Code:
## LoadOnDemand: 1 ## LoadWith: Blizzard_Collections Lua Code:
and because MountOptionsMenu_Init is a standalone function (not a method of C_MountJournal): Lua Code:
This will run your code after the original functions have completed running.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 11-20-20 at 09:09 PM. |
|
11-21-20, 03:57 AM | #3 |
thanks for the fast reply
i tried this, but Lua Code:
that doesn't seem to get called, and i believe the problem here is that this function only gets called in the Loading-Phase of Blizzard_Collections so if i hook into it after it's loaded my hook never gets called, but also hooking before Blizzard_Collections is loaded doesn't work because then it isn't defined yet ... i think any ideas ? maybe i need to call it again after i hooked into it ... aaaaand that worked just tested it with this line just below the hook call: Lua Code:
big thanks for your help ! edit: after some more testing and writing i came across an other problem, using either Lua Code:
Lua Code:
only works if i click the Button in the MountJournal-Panel, but not if i track it in my hotbars and click it there :/ also regardless if hooksecurefunc(...) works it is probably not what i want in this case, because i want to replace some functionality of SummonByID(0) and not just do stuff afterwards, which means i need to replace the call (at least when its called with 0 ) Last edited by Draugor : 11-21-20 at 07:57 AM. |
|
11-21-20, 09:29 AM | #4 |
Your code for the hooked MountOptionsMenu_Init function doesn't seem to require any information so the hook itself is not required. Just run your code when your addon loads or when you've detected the collections addon loading, whichever way you're doing it.
I can't see where you're using C_MountJournal.SummonByID so I don't know what you are trying to do with it but I can't imagine that trying to replace it with you own code is going to work.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
11-21-20, 11:24 AM | #5 |
as i want to add an extra option to the context menu of the mountjournal i need to hook to that function as i still need the buttons blizzard is adding (un/favorite, cancel and un/mount) so thats fine, that part is working and doing what it should.
what i want to do with SummonByID is the following: if ID is not 0 just call C_MountJournal.SummonByID else - choose a random mount from your favorites after a different logic then the blizzard one - call SummonByID with ID i provide decided by my logic that works so far, but only when i click the button in the journal or use a macro with Code:
/run C_MountJournal.SummonByID(0) edit: pastebin with everything i have currently: https://pastebin.com/iDBy0dhF Last edited by Draugor : 11-21-20 at 11:28 AM. |
|
11-21-20, 01:23 PM | #6 |
I suspect you're trying to do two different things that need different approaches
Updating the menu requires the Blizzard Collection addon to be loaded so that needs to be tracked. If you're not hooking the summon function until the collection is loaded then any call to summon won't have your "extra" bits until the Collections have been loaded (either by opened the collection UI or loading the addon yourself). This will require you to track ADDON_LOADED for when the Blizzard Collection loads and update the menu then, but also hook the Summon function when "your" addon loads (as your character is entering the world). Something like: (remove the LoadOnDemand and LoadWith lines from the .toc if you have them) Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 11-22-20 at 12:57 AM. |
|
11-23-20, 03:38 AM | #7 |
hmm sadly removing the loadWith and LoadOnDemand and putting the menuInit in ADDON_LOADED doesn't work either, now the context menu doesn't show up at all, although that worked before.
And even with this approach the hook for the "Summon Random Favorit Mount"-button gets called only when i manually press it in the MountCollection tab and not if i drag it on my hotbars :/ is it possible the dragged button becomes a spell and thats why it doesn't call the hook anymore ? any other ideas ? appreciate your help, though i mean last resort would be to auto-create a macro with just "/run C_MountJournal.SummonById(0)", because that works, and see if my addon can replace the "Summon Random Favorit Mount"-button in the hotbars with it. (or notify the user to replace the actionbar spell manually, but i would prefer if it just works out of the box) |
|
11-23-20, 09:51 AM | #8 |
If comment out your current code, copy/paste the code above and use that instead, it should work.
If you create a macro with: Code:
/run C_MountJournal.SummonByID(0) I didn't do anything with the menu other than add the "Exception" entry to it.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
11-23-20, 12:03 PM | #9 | |
yeah, as stated above, using a macro works fine, but i wanted it to work without a macro.
oh well
anyway i think i revert to your code from before and use it with the loadOnDemand part, that worked for everything except the hotbar-spell, but as that seemingly doesn't work without a macro anyway it should be fine. thanks again for all your help, wouldn't have come this far without it ! |
||
WoWInterface » Developer Discussions » Lua/XML Help » Hook into a MountJournal function ? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|