View Single Post
05-25-21, 03:04 PM   #17
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by phage View Post
Yes, I could use the help. I have a hard time understanding lua and explaining what I mean. What I meant was creating an add-on that would be able to do all the functions within one key but have multiple key presses that perform different functions. I wasn't sure how to word that initially.
I'd do it like this:

Lua Code:
  1. local binding = "SPACE";
  2. local target = "Collector Unta";
  3.  
  4. local UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown = UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown;
  5.  
  6. local button = CreateFrame("Button", "PhagesCuddleUntaButton", UIParent, "SecureActionButtonTemplate");
  7. button:RegisterForClicks("AnyUp", "AnyDown");
  8. button:SetAttribute("type", "macro")
  9. button:SetAttribute("macrotext", "/cast [nomounted] Mighty Caravan Brutosaur\n/targetexact "..target);
  10. button:SetScript("PostClick", function(self)
  11.     if (not InCombatLockdown() and UnitExists("target") and UnitName("target") == target) then
  12.         SetOverrideBinding(self, true, binding, "INTERACTTARGET");
  13.     end
  14. end);
  15.  
  16. button.Reset = function(self)
  17.     ClearOverrideBindings(self);
  18.     SetOverrideBindingClick(self, false, binding, self:GetName());
  19. end
  20.  
  21. button:RegisterEvent("PLAYER_ENTERING_WORLD");
  22. button:RegisterEvent("PLAYER_TARGET_CHANGED");
  23. button:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED");
  24.  
  25. button:SetScript("OnEvent", function(self, event)
  26.     if (not InCombatLockdown() and (event == "PLAYER_ENTERING_WORLD" or (event == "PLAYER_TARGET_CHANGED" and (not UnitExists("target") or UnitName("target") ~= target)) or event == "PLAYER_MOUNT_DISPLAY_CHANGED" and not IsMounted())) then
  27.         self:Reset();
  28.     end
  29. end);

Simple logic: If Unta is the target it interacts with her, otherwise it mounts up (if not mounted) and also tries to target Unta.

Seems to work fine on the PTR (can't test on live because my subscription just expired and token prices are ridiculous ), only issue is that it will try to mount up again if you press the key again exactly before the mount cast finished (propably dependant on spell-queuing settings, you'll have to try it yourself if it's annoying).
  Reply With Quote