Thread Tools Display Modes
12-27-18, 03:46 PM   #1
Uggers
A Fallenroot Satyr
 
Uggers's Avatar
Join Date: May 2008
Posts: 26
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
  Reply With Quote
12-27-18, 04:33 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-28-18, 01:34 PM   #3
Uggers
A Fallenroot Satyr
 
Uggers's Avatar
Join Date: May 2008
Posts: 26
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
  Reply With Quote
12-28-18, 01:51 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-28-18 at 10:31 PM.
  Reply With Quote
12-29-18, 06:43 AM   #5
Uggers
A Fallenroot Satyr
 
Uggers's Avatar
Join Date: May 2008
Posts: 26
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
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » IsMounted API Help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off