WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Trying to make my vanilla frame work in Classic--SendAddonMessage (https://www.wowinterface.com/forums/showthread.php?t=57474)

Furyswipes 09-09-19 03:42 PM

Trying to make my vanilla frame work in Classic--SendAddonMessage
 
Hi folks.
In vanilla, I had written a /find command that would have everyone report an item in their bags (for multiboxing) using the SendAddonMessage command.

I created the frame in Classic, and no errors (lua errors ARE enabled), but it doesn't do anything. I don't think the CHAT_ADDON_MSG event is even firing in my party members.

Can you see what i'm doing wrong?
SLASH_FIND1="/find"
SlashCmdList["FIND"]=function(item)
if UnitInRaid("player") then
C_ChatInfo.SendAddonMessage("NORMAL","FSMB_FIND",item,"RAID")
else
C_ChatInfo.SendAddonMessage("NORMAL","FSMB_FIND",item)
end
end
C_ChatInfo.RegisterAddonMessagePrefix("FSMB_FIND")
FSMB = CreateFrame("Button","FSMB",UIParent)
-- register the events we want to use (this is why we made the frame)
FSMB:RegisterEvent("ADDON_LOADED") -- register event "ADDON_LOADED"
FSMB:RegisterEvent("CHAT_MSG_ADDON")
FSMB:RegisterEvent("CONFIRM_SUMMON")
FSMB:RegisterEvent("RESURRECT_REQUEST")
FSMB:RegisterEvent("PLAYER_LOGIN")
FSMB:RegisterEvent("UI_ERROR_MESSAGE")
FSMB:RegisterEvent("AUTOFOLLOW_END")
FSMBtooltip=CreateFrame("GAMETOOLTIP", "FSMBtooltip", UIParent, "GameTooltipTemplate")
Print=print
function FSMB:OnEvent()
if (event == "CHAT_MSG_ADDON") then
Print("Addon message recieved from"..arg3)
if arg1=="FSMB_FIND" then
print("Got find request for "..item)
item=arg2
MB_Find(item)
end
elseif event == "CONFIRM_SUMMON" then
elseif event == "RESURRECT_REQUEST" then
-- this event fires when you get a resurrect request
AcceptResurrect() -- accepts resurrection
StaticPopup_Hide("RESURRECT_NO_TIMER"); -- hides popup frame
StaticPopup_Hide("RESURRECT_NO_SICKNESS"); -- hides popup frame
StaticPopup_Hide("RESURRECT"); -- hides popup frame
elseif (event == "UI_ERROR_MESSAGE") then
elseif (event == "AUTOFOLLOW_END") then
end
end
FSMB:SetScript("OnEvent", FSMB.OnEvent) -- event handler

Xrystal 09-09-19 08:03 PM

I've not used this element of the addon api so am not 100% sure of the accuracy of what I am saying but ..

I believe Blizzard has made changes to Classic so that certain automated/communication addons will not work.

https://eu.forums.blizzard.com/en/wo...-lfg/72495/474

It could also be that a later change made to the api since the original Classic has been retained in the new Classic and that is affecting your addon.

So, have you tested your addon code in the Retail version to see if it works there. If it doesn't work there in a similar way then that could mean my last suggestion is the more likely.

Are there any addons that do something similar that does work in Classic that you can look at to see what they do to make it work ?

Hopefully someone with more knowledge to these types of addons will be able to add more.

Fizzlemizz 09-09-19 08:24 PM

If the sendChat does work, your event handler doesn't have any parameters to "receive" any events and the if/elseif checks will always fail.

Code:

function FSMB:OnEvent(event, ...)
        local arg1, arg2, arg3 = ...

You might want to look into C_ChatInfo.SendAddonMessage as I think the prefix is supposed to be the first parameter and I'm not sure the others are correct.

Seerah 09-10-19 09:48 AM

Implicit arg1, arg2, etc. was removed long ago. Now you must define any parameters passed to your function that you wish to use. (See Fizzlemizz's post above.)

erispope 09-27-19 05:13 AM

Quote:

Originally Posted by Fizzlemizz (Post 333680)
If the sendChat does work, your event handler doesn't have any parameters to "receive" any events and the if/elseif checks will always fail.

Code:

function FSMB:OnEvent(event, ...)
        local arg1, arg2, arg3 = ...

You might want to look into C_ChatInfo.SendAddonMessage as I think the prefix is supposed to be the first parameter and I'm not sure the others are correct.

Quick aside - sending the "containing" table/object is only needed when a function is declared as Class:Method. A simple dot just means it is temporarily housed in that table and you can use local SendAddonMessage =C_ChatInfo.SendAddonMessage if you want without having to pass in C_ChatInfo.

I'm sure I explained it poorly,but the : Vs . Rule is what I use (or if the function requires self as first parameter which is functionally equivalent to having the : ).

SDPhantom 09-27-19 08:12 AM

The debate of colon and dot notation of calling is off topic here and doesn't even apply to your own example. It's not even a function call, you're just storing a local reference of a function.


All times are GMT -6. The time now is 11:55 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2019 MMOUI