Originally Posted by kraftman
I think all gf's should have a "Mount Me!" button
|
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.
Originally Posted by kraftman
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.
|
I had it as the variables previously, but it didn't really matter: The addon wasn't hitting that point, since the event wasn't firing (at all) when I mounted up. They were changed as a last resort to get it working
Originally Posted by tsadok
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.
|
Didn't think of that, but it makes it work all the same. Thanks.
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)
The person being followed uses this instead of their normal mounts:
Code:
/script if(not IsMounted()) then CallCompanion("MOUNT", MOUNT_POSITION_INT) SendAddonMessage("FH", ("flying" or "ground"), "WHISPER", ("PERSON_FOLLOWING_YOU") else Dismount() end