Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-17-09, 07:41 AM   #1
Exawatt
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 36
Mounting event

My girlfriend and I quest together all the time, and she's quite fond of /follow. This addon I'm making for her is supposed to display a "Mount Me" button when I begin to mount up while she's following me. It also selects the correct mount (i.e. flying or ground). For some reason I can't seem to get the UNIT_SPELLCAST_START to fire, and I can't figure out why. I've tried UNIT_SPELLCAST_SEND as well, with no luck. I do manage to get the UNIT_SPELLCAST_SUCCEEDED event to fire, but it comes three seconds after I want this addon to display itself.

The window displays fine, and the mounts are selected properly. The only problem is the event notification.

lua Code:
  1. --Determine Correct Mount
  2. local ground, flying
  3. for i=1,GetNumCompanions("MOUNT") do
  4.     local _, creatureName = GetCompanionInfo("MOUNT", i)
  5.     if( creatureName == "Dreadsteed" ) then
  6.         ground = i
  7.     end
  8.     if( creatureName == "Green Wind Rider" ) then
  9.         flying = i
  10.     end
  11. end
  12.  
  13. --Ground Mounting Function
  14. local function MountGround()
  15.     CallCompanion("MOUNT", ground)
  16.     FollowHelper:Hide()
  17. end
  18.  
  19. --Flying Mounting Button
  20. local function MountFlying()
  21.     CallCompanion("MOUNT", flying)
  22.     FollowHelper:Hide()
  23. end
  24.  
  25. --Boolean "Following" flag
  26. local FH_isFollowing = false
  27.  
  28. --Event function
  29. local function FollowHelper_EventHandler(self, event, ...)
  30.     if( event == "UNIT_SPELLCAST_START" and arg1 == "Chillah" ) then
  31.         if( arg2 == "Swift Zhevra" ) then
  32.             mountButton:SetScript("OnClick", MountGround)
  33.             FollowHelper:Show()
  34.         elseif( arg2 == "Blue Wind Rider" ) then
  35.             mountButton:SetScript("OnClick", MountFlying)
  36.             FollowHelper:Show()
  37.         end
  38.  
  39.     elseif( event == "AUTOFOLLOW_BEGIN" and arg1 == "Chillah" ) then
  40.         FH_isFollowing = true
  41.        
  42.     elseif( event == "AUTOFOLLOW_END" ) then
  43.         FH_isFollowing = false
  44.     end
  45. end
  46.  
  47. --Create frames and such
  48. local frame = CreateFrame("Frame", "FollowHelper")
  49. frame:SetFrameStrata("HIGH")
  50. frame:ClearAllPoints()
  51. frame:SetPoint("CENTER", UIParent, "CENTER")
  52. frame:SetWidth(75)
  53. frame:SetHeight(50)
  54. frame:RegisterEvent("UNIT_SPELLCAST_START")
  55. frame:RegisterEvent("AUTOFOLLOW_BEGIN")
  56. frame:RegisterEvent("AUTOFOLLOW_END")
  57. frame:SetScript("OnEvent", FollowHelper_EventHandler)
  58. frame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
  59.                    edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
  60.                    tile = true, tileSize = 16, edgeSize = 16,
  61.                    insets = { left = 4, right = 4, top = 4, bottom = 4 }})
  62.  
  63. --Create "Mount Me!" button
  64. local mountButton = CreateFrame("Button", "FH_MountButton", FollowHelper, "UIPanelButtonTemplate")
  65. mountButton:SetWidth(75)
  66. mountButton:SetHeight(25)
  67. mountButton:ClearAllPoints()
  68. mountButton:SetPoint("TOPLEFT", FollowHelper, "TOPLEFT")
  69. mountButton:SetText("Mount me!")
  70.  
  71. --Create "Do Nothing." button
  72. local cancelButton = CreateFrame("Button", "FH_CancelButton", FollowHelper, "UIPanelButtonTemplate")
  73. cancelButton:SetWidth(75)
  74. cancelButton:SetHeight(25)
  75. cancelButton:ClearAllPoints()
  76. cancelButton:SetPoint("TOPLEFT", FollowHelper, "TOPLEFT", 0, -25)
  77. cancelButton:SetText("Do Nothing.")
  78. cancelButton:SetScript("OnClick", function() FollowHelper:Hide() end)
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Mounting event


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