I've improved on the code a bit since my last post. I made my own AutoRoll addon and I'm in the middle of testing it. It doesn't use the code I posted, instead, I wrote a function that's hooked into UIParent's OnEvent handler.
Here's the modified section that handles the StaticPopup.
lua Code:
UIParent:HookScript("OnEvent",function(self,event,...)
if event=="CONFIRM_LOOT_ROLL" or event=="CONFIRM_DISENCHANT_ROLL" then
if StaticPopup_FindVisible("CONFIRM_LOOT_ROLL",...) then
ConfirmLootRoll(...);
StaticPopup_Hide("CONFIRM_LOOT_ROLL",...);
end
elseif event=="LOOT_BIND_CONFIRM" then
if StaticPopup_FindVisible("LOOT_BIND",...) then
ConfirmLootSlot(...);
StaticPopup_Hide("LOOT_BIND",...);
end
end
end);
The '...' holds all the args passed in by the event, this needs to be defined in the function parameters too.
Note that these pieces of code are exactly the same: ('...' can hold an unlimited number of returns, this is an example of a function that only wants 3)
Code:
function func(...)
local arg1,arg2,arg3=...;
-- Do something here
end
Code:
function func(arg1,...)
local arg2,arg3=...;
-- Do something here
end
Code:
function func(arg1,arg2,arg3)
-- Do something here
end