Thread Tools Display Modes
11-23-22, 02:11 PM   #1
BustleNation
A Defias Bandit
Join Date: Nov 2022
Posts: 3
C_Timer.After() not sending messages in Open World

Hi all - I am very new to programming in general and would appreciate any insight or help

I am working on an addon that will tell a joke in two parts when a button is pressed. The second part coming after a 5 second delay. Doing some searching it seems like C_Timer.After() is what I'm looking for. Inside of an instance it works correctly. However in the open world it is giving me the error "Interface action failed because of an Addon"

Here is the code that I have:

Code:
f.JokeButton:SetScript("OnClick", function()
  f.JokeButton:Disable()
  SendChatMessage("Why did the chicken cross the road?", "SAY")
  C_Timer.After(5, function () SendChatMessage("to get to the other side", "SAY") end)
  C_Timer.After(5, function () f.JokeButton:Enable() end)
end)
The C_Timer.After works for re-enabling the button after 5 seconds - just not for saying the second part ("to get to the other side").


I'd appreciate any thoughts! Thanks!
  Reply With Quote
11-23-22, 05:50 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Addons cannot send messages to SAY or YELL when outside instances. Public channels are also restricted, but everywhere.
  Reply With Quote
11-23-22, 11:10 PM   #3
BustleNation
A Defias Bandit
Join Date: Nov 2022
Posts: 3
Originally Posted by Kanegasi View Post
Addons cannot send messages to SAY or YELL when outside instances. Public channels are also restricted, but everywhere.
I appreciate the insight. It's weird that it'll let me do the first part in Say or Yell outside but anything connected to the C_Timer.After() it wont. Even if I do two back to back SendChatMessages without C_Timer.After() works.
  Reply With Quote
11-24-22, 01:54 AM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
Originally Posted by BustleNation View Post
I appreciate the insight. It's weird that it'll let me do the first part in Say or Yell outside but anything connected to the C_Timer.After() it wont. Even if I do two back to back SendChatMessages without C_Timer.After() works.
That's because you send on a click which is a hardware event.
/say outside is protected not forbidden, you can still type /say Hello there! or you can click a button to send.
You cannot automate it, which is what a timed send would be.
  Reply With Quote
11-25-22, 10:23 PM   #5
BustleNation
A Defias Bandit
Join Date: Nov 2022
Posts: 3
Originally Posted by Dridzt View Post
That's because you send on a click which is a hardware event.
/say outside is protected not forbidden, you can still type /say Hello there! or you can click a button to send.
You cannot automate it, which is what a timed send would be.
Gotcha - that makes sense. Thank you for the info!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » C_Timer.After() not sending messages in Open World

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