Originally Posted by sezz
I'd do it like this:
Lua Code:
local binding = "SPACE"; local target = "Collector Unta"; local UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown = UnitExists, UnitName, SetOverrideBinding, ClearOverrideBindings, SetOverrideBindingClick, IsMounted, InCombatLockdown; local button = CreateFrame("Button", "PhagesCuddleUntaButton", UIParent, "SecureActionButtonTemplate"); button:RegisterForClicks("AnyUp", "AnyDown"); button:SetAttribute("type", "macro") button:SetAttribute("macrotext", "/cast [nomounted] Mighty Caravan Brutosaur\n/targetexact "..target); button:SetScript("PostClick", function(self) if (not InCombatLockdown() and UnitExists("target") and UnitName("target") == target) then SetOverrideBinding(self, true, binding, "INTERACTTARGET"); end end); button.Reset = function(self) ClearOverrideBindings(self); SetOverrideBindingClick(self, false, binding, self:GetName()); end button:RegisterEvent("PLAYER_ENTERING_WORLD"); button:RegisterEvent("PLAYER_TARGET_CHANGED"); button:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED"); button:SetScript("OnEvent", function(self, event) 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 self:Reset(); end 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?