Thread Tools Display Modes
09-09-19, 03:42 PM   #1
Furyswipes
A Kobold Labourer
Join Date: Sep 2019
Posts: 1
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
  Reply With Quote
09-09-19, 08:03 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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.
__________________
  Reply With Quote
09-09-19, 08:24 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-09-19 at 08:30 PM.
  Reply With Quote
09-10-19, 09:48 AM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
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.)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-27-19, 05:13 AM   #5
erispope
A Deviate Faerie Dragon
Join Date: Sep 2019
Posts: 10
Originally Posted by Fizzlemizz View Post
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 : ).
  Reply With Quote
09-27-19, 08:12 AM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Trying to make my vanilla frame work in Classic--SendAddonMessage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off