View Single Post
05-25-21, 11:45 PM   #18
phage
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 15
Originally Posted by sezz View Post
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).

Very cool! I tried to install it by saving it as a .lua file, creating a toc with the proper callings, but I couldn't turn it on from my add-ons list. Is there something else I need to do for it to appear on that list?
  Reply With Quote