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 |
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. |
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, ...) |
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.)
|
Quote:
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 : ). |
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 09:36 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI