WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   C_Timer.After() not sending messages in Open World (https://www.wowinterface.com/forums/showthread.php?t=59369)

BustleNation 11-23-22 02:11 PM

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!

Kanegasi 11-23-22 05:50 PM

Addons cannot send messages to SAY or YELL when outside instances. Public channels are also restricted, but everywhere.

BustleNation 11-23-22 11:10 PM

Quote:

Originally Posted by Kanegasi (Post 341665)
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.

Dridzt 11-24-22 01:54 AM

Quote:

Originally Posted by BustleNation (Post 341666)
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.

BustleNation 11-25-22 10:23 PM

Quote:

Originally Posted by Dridzt (Post 341667)
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!


All times are GMT -6. The time now is 05:49 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI