Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. -- Create a new button type
  2. UnitPopupButtons["GUILD_INVITE"] = { text = "Invite to Guild", dist = 0 };
  3.  
  4. -- Add it to the FRIEND and PLAYER menus as the 2nd to last option (before Cancel)
  5. table.insert(UnitPopupMenus["FRIEND"], #UnitPopupMenus["FRIEND"]-1, "GUILD_INVITE");
  6. table.insert(UnitPopupMenus["PLAYER"], #UnitPopupMenus["FRIEND"]-1, "GUILD_INVITE");
  7.  
  8. -- Hook ToggleDropDownMenu with your function
  9. hooksecurefunc("ToggleDropDownMenu", MyButton_Setup);
  10.  
  11. -- Your function to setup your button
  12. function MyButton_Setup(level, value, dropDownFrame, anchorName, xOffset, yOffset, menuList, button, autoHideDelay)
  13.     -- Make sure we have what we need to continue
  14.     if (dropDownFrame and level) then
  15.         -- Just so we don't have to concat strings for each interval
  16.         local buttonPrefix = "DropDownList" .. level .. "Button";
  17.         -- Start at 2 because 1 is always going to be the title (i.e. player name) in our case
  18.         local i = 2;
  19.         while (1) do
  20.             -- Get the button at index i in the dropdown
  21.             local button = _G[buttonPrefix..i];
  22.             if (not button) then break end;
  23.             -- If the button is our button...
  24.             if (button:GetText() == UnitPopupButtons["GUILD_INVITE"].text) then
  25.                 -- Make it invite the player that this menu popped up for (button at index 1)
  26.                 button.func = function() print("1"); end
  27.                 -- Break the loop; we got what we were looking for.
  28.                 break;
  29.             end
  30.             i = i + 1;
  31.         end
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement