Great questions Krazy and nice to meet someone who wants to learn more!
Originally Posted by
Krazyito
Wow dude, I'm surprised that you're still here doing stuff for 3+ years on the same thread. I've recently decided to start making some custom Auras in preparation of WoD, but a lot of random code I find to try to learn just leaves me trying to find out more bits and pieces that I don't know. I'll ask here when I need help, but is there somewhere I can reference to learn more? Is it a matter of just knowing LUA? or is there a weak aura reference guide somewhere?
Most of the help I provide here seems to focus on custom Lua code, so definitely the primary resource for learning would just be basic Lua knowledge. This book is a good starting point for someone with basic programming knowledge. Beyond that, for WeakAura specifics, it's mostly just lots of use along with trial and error. By and large, the custom code answers I provide only use WeakAuras as a "shell", and are equivalent of small addons that are using very useful and already existent WeakAuras display options and visuals to process what is shown. Unfortunately there isn't a WeakAuras reference per se, but the best official source of information is the pages located on WoWAce (though they are extremely dated).
Aside from Lua itself and how the syntax works, your other main reference will be the World of Warcraft API, so you can quickly find functions that may (or may not) exist to accomplish what you're after. WoWProgramming has a good full list, and if you want something more "sectioned" off then try the same basic API list from WoWPedia.
You'll also want to bookmark the Events list available in-game, as well as the Lua functions that are innately built into the WoW client.
Finally, to start playing around with Lua stuff as it related to WoW, one of the most helpful things you can do is grab two addons:
WowLua: http://www.wowinterface.com/download...66-WowLua.html
DevTools: http://www.wowinterface.com/download...-DevTools.html
WowLua in particular is immensely helpful when learning Lua and how it can be utilized within WoW, because the addon allows you to essentially "simulate" an Lua environment and run commands or write scripts from in-game. You can create infinite "pages", save them for later use, and essentially write Lua code to your heart's content. It's a must have for sure.
DevTools isn't nearly as vital, but it adds one very useful /slash command which is /dump. Using this command with ANYTHING following it will output the results in a nice, human-readable format. Another lifesaver for sure.
Originally Posted by
Krazyito
1) Next my actual questions. When I was scouring the net I found this thread:
http://www.wowace.com/addons/project...-progress-bar/
Basically could you tell me what this portion of the code is used for?
Code:
function(_, _, message, _, _, source, _, destGUID, dest, _, _, spellName)
All the other code I've seen uses that space empty in front of function(). What is this space used for?
I'm a little confused by your use of the words "in front of function" since I see nothing in your example that is in front of it. I'm going to assume you mean the underscore (_) within the parameter list for now, but correct me if I am misunderstanding (and if so, provide an example of the other code you're seeing that you are referencing).
The use of the underscore for most people is just simply a placeholder variable; a shorter way to fill that parameter than would otherwise be necessary.
In Lua, an identifier (often thought of as a variable from other languages) can be defined by basically any alphanumeric series of characters, and also an underscore. So for example, these two snippets would produce identical results:
Code:
local foo = 'bar'
function MyFunction(value)
print(value)
end
MyFunction(foo)
Code:
local _ = 'bar'
function MyFunction(value)
print(value)
end
MyFunction(_)
In both cases, we're just passing our initialized variable at the top (with an identifier of foo in the first and _ in the second) to MyFunction, which then prints it out. So the result of both would be output of the string bar.
So, when you see code like your example, where underscores are used within a series of parameters, it is just shorthand for the author of the code to insert a parameter into that place without writing a longer identifier. It allows the function to accept the required number of total parameters, but by using proper named identifiers for the parameters we care about, and then underscores otherwise, it saves us from typing more than necessary (and makes the code look cleaner to many people). Let's see how this is used in your example:
This function snippet is being used in a trigger function for the event COMBAT_LOG_EVENT_UNFILTERED, which is a very complex event that is fired for basically everything that occurs in game related to combat. By tracking that event, WeakAuras will pass along all the arguments into the Trigger function seen below:
Code:
function(_, _, message, _, _, source, _, destGUID, dest, _, _, spellName)
The author wishes to make use of five of the arguments passed by the COMBAT_LOG_EVENT_UNFILTERED event, and ignore the others. However, if we were to simply rewrite the function and parameter list with proper/appropriate names for everything that is being passed into the function from above, it would look like this:
Code:
function(event, timestamp, message, hideCaster, sourceGUID, source, sourceFlags, destGUID, dest, destFlags, spellId, spellName)
By utilizing the underscores for parameters such as event or timestamp, the author is saving him or herself a bit of typing (and making it easier to read), but from the perspective of Lua or the functions specifically, there is no impact using proper names or underscores.
So if we look at the full function with that in mind, you can get a sense of what is being accomplished:
Code:
function(_, _, message, _, _, source, _, destGUID, dest, _, _, spellName)
if (message == "SPELL_AURA_APPLIED" and UnitIsUnit(source or "", "player") and spellName and spellName:find("Polymorph")) then
WeakAuras_Polymorph_Mob_Name = dest
WeakAuras_Polymorph_Start = GetTime()
return true
end
if (message == "SPELL_AURA_REFRESH" and UnitIsUnit(source or "", "player") and spellName and spellName:find("Polymorph")) then
WeakAuras_Polymorph_Start = GetTime()
end
return false
end
The author is only utilizing the parameters of message, source, and spellName in fact, as passed in from the COMBAT_LOG_EVENT_UNFILTERED event. Thus the actual function and parameters could be cleaned up even more to get rid of more unused parameters (though it is only for visibility):
Code:
function(_, _, message, _, _, source, _, _, _, _, _, spellName)
Hope that answers that question but as I said, let me know if not.
Originally Posted by
Krazyito
2) Are variables I make in a custom trigger local to all parts of that specific aura? (such as custom untrigger / duration info / display, etc...)
Technically not "local" variables, as defined by: local foo = 'bar', but yes if you leave off the local declaration, the variable will become "scoped" to the parent scope that houses all the functions within your Display, and be available across them all.
For example, consider two basic functions:
Code:
function foo()
print(myVar)
end
function bar()
local myVar = 'hello'
end
If we execute the code:
We get the output:
Nil is printed both times because by using the local declaration for myVar, that variable is "scoped" to only within our bar function, and an identifier with the same name used elsewhere is considered unique and separate within Lua, so print(myVar) in foo considers it nil.
However, by removing the local declaration, like so:
Code:
function foo()
print(myVar)
end
function bar()
myVar = 'hello'
end
And then performing the same execution afterward:
We get the following output:
The first time foo runs the myVar variable is nil, but after bar is run it now exists outside of the function scope where it was declared, and thus the second call to foo results in the expected output of hello.
TLDR; I personally don't like relying on it, but yes if you don't declare variables locally, you can access them within WeakAura Displays.
Originally Posted by
Krazyito
3) Is there a way to make multiple instances of an aura based on specific units? Example: I have boss1 that I want to track energy of. but during he spawns a boss2 and boss3 that I also want to see the enrgy of for the same purpose / triggers of that aura. I understand how I can get the name of the bosses and label them, I just don't know how to make the extra instances without just making a whole new aura for each specific boss.
Again I may not fully understand the question, but one slick feature WeakAuras has is called Auto-Cloning, which in some situations allows WeakAuras to dynamically create duplicate Displays for multiple targets of the same trigger (such as Auras and such). However, the availability of this function is very limited, and most importantly, I don't believe it can be used for any non-friendly units. (For future reference, you'll see an Auto-Cloning popup when you are selecting "Multiple Targets" in your Trigger setup).
So the short answer is, for tracking energy and specifically of enemies, just right-click > Duplicate is your best bet. If you stick them all in a Dynamic Group, you can make WeakAuras display then in a pretty way and space them out and all that.