|
05-17-09, 07:41 AM | #1 |
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:
|
|
![]() |
05-17-09, 08:31 AM | #2 |
I think all gf's should have a "Mount Me!" button
![]() More seriously though, have you printed arg1 and arg2 to check they are what you think they are? I think the first argument is the unit ("target") rather than the unitname. Also its better to use the variables passed in ... than the globals. eg local arg1, arg2 = ... Hope this helps! Last edited by kraftman : 05-17-09 at 10:43 AM. |
|
![]() |
05-17-09, 09:25 AM | #3 |
I got my troll a hawkstrider and wanted him to say stuff when he mounted. I registered a frame to all events and got nothing when I mounted, so I suspect there isn't a specific mounting event, strange as that may seem. One thing I didn’t get round to trying was periodically testing for the mount buff (or these days, events).
If it's just between you two, you could attach a script to your mount macro like: /script SendAddonMessage("Gf&me", "Ground", "WHISPER", "Gfsname") and her client could pick that up. |
|
![]() |
05-17-09, 01:26 PM | #4 | ||
It was originally going to say "Ryan is mounting" (then give options to mount), but now I'm going to have it toss in a randomly-occuring message to "Mount Ryan!", just for that gem.
![]()
![]() Though my addon is working now, I'd still like to know why the original didn't work. If anyone could shed some light on the UNIT_SPELLCAST_START and/or UNIT_SPELLCAST_SEND events, that'd be appreciated. [EDIT] Oh, and if anyone was interested; here's the finished addon (sans my own tweaks): FollowMounter.lua Code:
--Settings local FH_FavGround = "Dreadsteed" --Ground mount to choose local FH_FavFlying = "Green Wind Rider" --Flying mount to choose --Determine Correct Mount Positions local FH_ground, FH_flying for i=1,GetNumCompanions("MOUNT") do local _, creatureName = GetCompanionInfo("MOUNT", i) if( creatureName == FH_FavGround ) then FH_ground = i end if( creatureName == FH_FavFlying ) then FH_flying = i end end --Ground Mounting Function local function FH_MountGround() CallCompanion("MOUNT", FH_ground) FollowHelper:Hide() end --Flying Mounting Function local function FH_MountFlying() CallCompanion("MOUNT", FH_flying) FollowHelper:Hide() end local FH_isFollowing = false --Boolean "Following" flag FH_Who = "" --Player you will be following --Event function local function FollowHelper_EventHandler(self, event, ...) if( event == "CHAT_MSG_ADDON" ) then local prefix, message, channel, sender = ... if( FH_isFollowing and prefix == "FH" and channel == "WHISPER" and sender == FH_Who ) then if( message == "ground" ) then --CallCompanion("MOUNT", FH_ground) --uncomment for automount --will not work if the person you are following quickly stops moving and mounts, --since you will still be moving for a second --comment out next two lines for automount FH_MountButton:SetScript("OnClick", FH_MountGround) FollowHelper:Show() elseif( message == "flying" ) then --CallCompanion("MOUNT", FH_flying) --uncomment for automount (see note above) --comment out next two lines for automount FH_MountButton:SetScript("OnClick", FH_MountFlying) FollowHelper:Show() end end elseif( event == "AUTOFOLLOW_BEGIN" ) then FH_Who = (...) FH_isFollowing = true elseif( event == "AUTOFOLLOW_END" ) then FH_isFollowing = false end end --Create frames and such local f = CreateFrame("Frame", "FollowHelper") f:SetFrameStrata("HIGH") f:ClearAllPoints() f:SetPoint("CENTER", UIParent, "CENTER") f:SetWidth(85) f:SetHeight(60) f:RegisterEvent("CHAT_MSG_ADDON") f:RegisterEvent("AUTOFOLLOW_BEGIN") f:RegisterEvent("AUTOFOLLOW_END") f:SetScript("OnEvent", FollowHelper_EventHandler) f:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "Interface/Tooltips/UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 4, right = 4, top = 4, bottom = 4 }}) f:Hide() --Create "Mount Me!" button local b = CreateFrame("Button", "FH_MountButton", FollowHelper, "UIPanelButtonTemplate") b:SetWidth(75) b:SetHeight(25) b:ClearAllPoints() b:SetPoint("TOPLEFT", FollowHelper, "TOPLEFT", 5, -5) b:SetText("Mount me!") --Create "Do Nothing." button b = CreateFrame("Button", "FH_CancelButton", FollowHelper, "UIPanelButtonTemplate") b:SetWidth(75) b:SetHeight(25) b:ClearAllPoints() b:SetPoint("TOPLEFT", FollowHelper, "TOPLEFT", 5, -30) b:SetText("Do nothing.") b:SetScript("OnClick", function() FollowHelper:Hide() end) Code:
/script if(not IsMounted()) then CallCompanion("MOUNT", MOUNT_POSITION_INT) SendAddonMessage("FH", ("flying" or "ground"), "WHISPER", ("PERSON_FOLLOWING_YOU") else Dismount() end Last edited by Exawatt : 05-17-09 at 03:34 PM. Reason: Added completed AddOn |
|||
![]() |
05-17-09, 09:23 PM | #5 |
I looked at UNIT_SPELLCAST_START and it returned "player" as the first argument when I mounted, so that could be your problem.
Also, using arg1 etc. is deprecated or obsolete. If it still works, arg1 may have been referring to the event frame, and arg3 might have been the unit. |
|
![]() |
05-17-09, 10:47 PM | #6 | |
I wasn't looking for my own event, though. Rather, character A begins mounting, and character B is waiting for the event to fire. |
||
![]() |
05-23-09, 11:57 AM | #7 |
I've been trying to get a code similar to this to work.
I need it to detect when casting a mount on a char thats in my group and tell me. Sadly I have the same problem as you. Also cant get the addon you posted to work either ![]()
__________________
Rogue [Combat] - 80 Paladin [Protection] - 80 Death Knight [Blood] - 77 Shaman [Elemental] - 77 Mage [Frost] - 76 Priest [Shadow] - 75 Hunter [Beast] - 72 |
|
![]() |
WoWInterface » Developer Discussions » Lua/XML Help » Mounting event |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
![]() |
![]() |
![]() |
|
|