WeakAuras: Shared functions withing a dynamic group
Is it possible to use some kind of "global" functions in WeakAuras environment, or global to a group, or to a dynamic group but still local in terms of WoW env? I could still refer to them when creating codes in Custom Triggers or Custom Text
[TL;DR] I have created and completed a dynamic group in WeakAuras which contains a set of progress bars, which in turn track random buffs when you apply Rogue's Roll the Bones (based on Muzgu in Wowhead). The problem is Roll the Bones produces a number of buffs out of six in total. In terms of WA, each buff works exactly the same. The only difference is the buff itself. I had to copy and paste a lot of functions and change only one line. Because I created codes for Custom Text and Custom Triggers, for each buff, it was very laborious and prone to error. It would be much more effective and optimised, if I could place the core functions somewhere else within WA environment with a single parameter "buff_name". For instance, for the buff "Broadsides", I created functions for custom text and custom trigger "Dynamic Info". The code for other buffs, such as "Jolly Roger", "Grand Melee", "Grand Melee", "Shark Infested Waters", "True Bearing", "Restless Blades", and "Buried Treasure" is exactly the same. I only change "buff_name". Below is an example of redundant functions and the third one which would handle everything in one place. Thanks Custom text: Lua Code:
Custom Trigger "Dynamic Info" Lua Code:
Lua Code:
|
I can't actually answer your question as I don't use WeakAuras, but you'll want to be careful about leaking your variables into the global environment:
Code:
-- Function for Custom Text lua Code:
edit: Actually, on the original topic, you may not be able to do what you want inside WeakAuras, but there's nothing stopping you from doing it outside of WeakAuras. Just create an addon whose name comes before "WeakAuras" in alphabetical order, and put your function in there as a global, with a nice unique name appropriate for a global: lua Code:
...and then call it in your WeakAuras function: lua Code:
|
You're missing one underscore,Phanx. 6th argument is duration ;)
|
Quote:
|
Thanks for you answer Phanx.
I have never done any addon before and have not a clue how to start -.- I know there is a TOC file which contains some info about. Maybe it's the time to start one ... I did not see any error. I though testing UnitBuff() would be enough. Thanks for the comment and suggestions on leaking variables as well. |
Quote:
|
Quote:
@FranekW: It's an online tool that creates an addon for you. All you have to do is type a name and paste in the code you want to be in it. |
Thanks for the link. My addon will be super basic :) I also found WoWWiki with plenty of links and suggestions.
Just one question. If I want to check if buff exists, is it all right if I just check UnitBuff() itself, e.g.: Lua Code:
or should I always test variables returned from the function: Lua Code:
Thanks |
If you just want to show that you have the buff, then yes, the first way will work.
If you want to show how much time is left on the buff, or any other information about it other than "it exists", then the only way to do that is by capturing the values returned by UnitBuff. |
All times are GMT -6. The time now is 12:06 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI