It's a variable argument and is a list of args. https://www.lua.org/pil/5.2.html
In a case like game events, where you could register several different events with quite different args, instead of naming every possible arg something generic you can just use ...
then, depending on the event in question, utilise the content differently.
Say you were using UNIT_AURA
and also ENCOUNTER_START
UNIT_AURA
sends just unit
. ENCOUNTER_START
sends encounterID, encounterName, difficultyID, groupSize
So you might set up your handler like:
local frame = CreateFrame("FRAME", "justANameAddonFrame") frame:RegisterEvent("UNIT_AURA") frame:RegisterEvent("ENCOUNTER_START") frame:SetScript("OnEvent", function(self, event, ...) if event == "UNIT_AURA" then local unit = ... -- do stuff elseif event == "ENCOUNTER_START" then local encounterID, encounterName, difficultyID, groupSize = ... -- do other stuff end end)
So, you see, in the case of UNIT_AURA
the variable ...
is just a single unitID. In ENCOUNTER_START
it is a list of 4 vars.
In a case like that, if you only wanted the 3rd value then you could either throw away the ones you don't want ( local _, _, this = ...
) or use select
( local this = select(3, ...)
)
Edit to add: Since you're using a unit event, you could bypass some of this by simply using https://wow.gamepedia.com/API_Frame_RegisterUnitEvent
I would use either of those scripts to see which addon is trying to send addon messages to a specific player
/run hooksecurefunc(C_ChatInfo, "SendAddonMessage", function(...) print(...) end) /run hooksecurefunc(C_ChatInfo, "SendAddonMessage", function(prefix, message, chatType, target) if chatType == "WHISPER" then print(prefix, message, chatType, target) end end)
Otherwise you can try to "grep" for SendAddonMessage through your Interface/AddOns folder with e.g. VS Code to get a hint https://i.imgur.com/2FCnXJc.png
Assuming you have your addon in some git repo (for instance using GitHub, highly recommended for hosting free software, alternatives being GitLabs and BitBucket)
If you are using windows, get git for windows: https://git-scm.com/download/win it comes with Git Bash which will let you run simple shell scripts like the one I wrote/linked above
Atom (and vscode which I prefer, it's more efficient) have Git integration too but I don't think on windows they can run bash scripts without addons
It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they're easier for our sausage fingers to click!
Here is link number 1 - Previous text "Git"
^Please ^PM ^/u/eganwall ^with ^issues ^or ^feedback! ^| ^Delete
function addon:CreateButtons(parentFrame, DungeonAmountFunc, DungeonInfoFunc, SetDropdownMenuFunc) local scale = self:GetButtonScale(DungeonAmountFunc())
if not parentFrame.BossesKilledButtons then parentFrame.BossesKilledButtons = {} end local buttons = parentFrame.BossesKilledButtons
for i = 1, DungeonAmountFunc() do local id, name = DungeonInfoFunc(i) local isAvailable, isAvailableToPlayer = IsLFGDungeonJoinable(id)
-- Only make a button if there's data for it, and it hasn't been already made. This gets called multiple times so it updates correctly when you open up more raids if isAvailable and isAvailableToPlayer and not buttons[id] and self.raidData[id] then
local button = self:CreateButton(parentFrame, scale) buttons[id] = button
button.dungeonID = id button.dungeonName = name
parentFrame.lastButton = button
-- I just realised a CheckButton might already have it's own FontString, but uh... whatever. button.number = self:CreateNumberFontstring(button)
button:SetScript("OnEnter", function(this) if this.tooltip then self:ShowTooltip(this) end end)
button:SetScript("OnClick", function(this) SetDropdownMenuFunc(this.dungeonID) self.UpdateArrow()
-- This is to override the automatic highlighting when you click the button, while we want to use that to show queue status instead. -- I've no idea why simply overriding this OnClick and not doing a SetChecked doesn't disable the behavior. -- I probably shouldn't be using a CheckButton at all, but the SpellBookSkillLineTabTemplate looks pretty nice for the job. this:SetChecked(this.checked) end) button.checked = false end end end
It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they're easier for our sausage fingers to click!
Here is link number 1 - Previous text "VLC"
^Please ^PM ^/u/eganwall ^with ^issues ^or ^feedback! ^| ^Delete
It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they're easier for our sausage fingers to click!
Here is link number 1 - Previous text "VLC"
^Please ^PM ^/u/eganwall ^with ^issues ^or ^feedback! ^| ^Delete
args is ONE parameter; ... is the varargs (variable argument) feature of Lua and may contain ALL the remaining arguments.
In your example, args would be the first parameter after "event", not all remaining ones. If it is nil then you may have called the event handler incorrectly - a common mistake is confusing function:method(...) and function.method() calls. The "self" argument can only be implicitly passed by function:method(...), as it is a shortcut for function.method(self, ...) in Lua (see PIL chapter 16).
Additionally, according to the article that was linked (and to Blizzard's interface code) the UNIT_BUFF event only carries the unit token (e.g., "player") as its payload. Many events notify you that information has changed, but not in which way. It is then your task to query the information you need by using other APIs.
The problem is that you're using the same variable to store the result of the AceDB call that you pass on to it. It doesn't really matter whether it's stored globally or not. When passing the reference, AceDB will set up the metatable on your SV table and assume that you'll let it manage the actual table while using the handle it returns afterwards. By saving the handle in the same table, you are implicitly telling Lua to save the entire database in there because the table is now using the __index metamethod (see Programming in Lua chapter 13) to look up the ACTUAL table that it is saving, and not (as you likely intended) the ORIGINAL table. Any direct reference to it will be "re-routed" using the __index function, if you will.
In other words, you can no longer refer to the table directly if it has a metatable with the index lookup by using its name. If you still need to access it, then you can use the rawget and rawset functions (see here) that bypass the lookup. That, however, would still be mis-using AceDB as it is intended :)
I got started using the WoW Programming and still use it as a reference. The core lua and xml hasn’t changed too much so it will sill be good for learning the base framework if creating addons. The api reference is going to be pretty outdated, but thankfully there are some good online references that weren’t around when those books first came out.
Seems you want to code your own addon UI? If so, first you have to learn how to program. The best book for programming in WoW and Lua (the script language WoW uses) is World of Warcraft Programming: A Guide and Reference for Creating WoW Addons, which will teach you the basic of programming, lua and WoW stuff. Good for completely novices and programmers that want to learn how to code for WoW.
Keep in mind though that UI programming is the hardest one when it comes to WoW because it requires a lot of knowledge of Lua and how WoW handles a bunch of stuff. That's why UI addons like Tuk and ElvUI have more than one programmer and thousands and thousands of lines of code. I don't know if you're already a programmer but, if you're not, start by making small things and then go bigger. The book I suggested you is a good way to start.