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 |
|
05-23-09, 01:24 PM | #8 |
Well the version I'm using now uses method tsadok proposed. The person mounting up changes their mount action into a macro which includes sending an addon message, then the AddOn frame listens for that message. If you wanted it to work with a group, change a couple of things:
Code:
local function MyAddon_EventHandler(self, event, ...) local prefix, message, channel, sender = ... if( prefix == "MA" and channel == "PARTY" ) then DEFAULT_CHAT_FRAME:AddMessage(sender.." is summoning their "..message.." mount.") end end local f = CreateFrame("Frame", "MyAddon") f:RegisterEvent("CHAT_MSG_ADDON") f:SetScript("OnEvent", MyAddon_EventHandler) Code:
/script if(not IsMounted()) then CallCompanion("MOUNT", %MOUNT_POSITION_INT%) SendAddonMessage("MA", %"flying" or "ground"%, "PARTY") else Dismount() end Maybe the event is busted? |
|
06-04-09, 04:19 AM | #9 |
Maybe COMPANION_UPDATE might do it? It's new as of 3.0
|
|
06-04-09, 12:07 PM | #10 |
That only has one argument (which only says "MOUNT") and it fires when the mount appears (end of casting), as well as when the mount is unsummoned (but does not differentiate between the two). There's no way to tell the difference between air and ground, or if the other person is mounting or unmounting.
It does seem to always fire, though, which is more than the others have been doing. |
|
06-06-09, 03:00 AM | #11 | |
|
||
WoWInterface » Developer Discussions » Lua/XML Help » Mounting event |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|