WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   IsMounted API Help (https://www.wowinterface.com/forums/showthread.php?t=56927)

Uggers 12-27-18 03:46 PM

IsMounted API Help
 
I'm trying to fix a portion of an addon but i'm a bit stuck.

The portion of the addon which causes a new random mount macro to be generate (I want this because it includes the tooltip and icon etc, is currently like this;

Code:

function MountManager:UNIT_SPELLCAST_SUCCEEDED(event, unit, spellName)
    if self.db.profile.autoNextMount and unit == "player" and spellName == GetSpellInfo(state.mount) then
        self:GenerateMacro()
    end
end

I believe that UNIT_SPELLCAST_SUCCEEDED no longer gives spell details so I dropped the (event, unit, spellName) and changed it to IsMounted, eventually trying a few things but currently I have


Code:

function MountManager:UNIT_SPELLCAST_SUCCEEDED()
    if self.db.profile.autoNextMount and unit == "player" and IsMounted() then
        self:GenerateMacro()
    end
end

any help would be appreciate as i'm a bit stuck now

Fizzlemizz 12-27-18 04:33 PM

According to the documentation, the payload (...) for UNIT_SPELLCAST_SUCCEEDED is:

Code:

unitTarget, Type = string, Nilable = false
castGUID, Type = string, Nilable = false
spellID, Type = number, Nilable = false


Uggers 12-28-18 01:34 PM

Thanks Fizzlemizz,

I have this a try;

Code:

function MountManager:UNIT_SPELLCAST_SUCCEEDED(event, unitTarget, spellName)
    if self.db.profile.autoNextMount and IsMounted() == true then
        self:GenerateMacro()
    end
end

a go, its not trigger of a successful case I don't think, its just picking up when I'm mounted, then it basically spam generates the macro in batches (throttled maybe?)

I guess it just need it to basically generate the macro upon a successful mount cast

Fizzlemizz 12-28-18 01:51 PM

Your original code seemed to be comparing spellName to a stored variable, possibly a mount name. Instead of the spell name, you can use the spell id.

Lua Code:
  1. local MountManager = CreateFrame("Frame")
  2. MountManager:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  3. function MountManager:UNIT_SPELLCAST_SUCCEEDED(event, unitTarget, castGUID, spellId)
  4.     print(unitTarget, castGUID, spellId)
  5. end
  6. MountManager:SetScript("OnEvent", function(self, event, ...)
  7.     MountManager[event](self, event, ...)
  8. end)

In the code above when I mount, I get a unitTarget of player and the spellId of the mount (17481 which is Rivendare's DeathCharger).
Code:

function MountManager:UNIT_SPELLCAST_SUCCEEDED(event, unitTarget, castGUID, spellId)
    if self.db.profile.autoNextMount and unit == "player" and spellId == select(7, GetSpellInfo(state.mount)) then
        self:GenerateMacro()
    end
end

Maybe I'm misunderstanding what your original code is trying to do.

Uggers 12-29-18 06:43 AM

Thanks again Fizzlemizz,

For reference the full Lua is here - https://pastebin.com/eTjahqd0

Basically its a random mount macro, and the trigger is meant to detect when you mount it picks a new random mount causing the macro to update icon/tooltip etc


All times are GMT -6. The time now is 03:37 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI