WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Delayed message in chat (https://www.wowinterface.com/forums/showthread.php?t=57798)

Nodos7 02-02-20 02:16 PM

Delayed message in chat
 
Hello, world!
I have this simple code:
Code:

function ButtonHelp_OnClick()
        if UnitIsPlayer("target") or UnitName("target") == nil then
    SendChatMessage("I need help!");
    SendChatMessage("Somebody, help!");
    else
        SendChatMessage("Help me, target!");
        SendChatMessage("Target, please!");
    end
end

How can I send a second message after first message in 3 seconds? Is there any timer for this in vanilla wow?

myrroddin 02-02-20 07:40 PM

https://wow.gamepedia.com/API_C_Timer.After

Nodos7 02-03-20 12:25 AM

Quote:

Originally Posted by myrroddin (Post 335070)

Could you please add the example of code? Will it work in WoW Classic?

Xruptor 02-03-20 07:00 AM

something like this
 
Quote:

Originally Posted by Nodos7 (Post 335071)
Could you please add the example of code? Will it work in WoW Classic?

There are several ways of using this function.

C_Timer.After(duration, callback)
duration is in seconds

Code:

C_Timer.After(1, function () SendChatMessage("I need help!") end)
C_Timer.After(2, function () SendChatMessage("Somebody, help!") end)
C_Timer.After(3, function () SendChatMessage("Too late I'm dead!") end)

or

Code:

local function doSomething()
  SendChatMessage("The world says, hello")
end

C_Timer.After(1, doSomething)


Nodos7 02-03-20 09:59 AM

Thank you! But i can't make this code working... It causes interface error and only display SendChatMessage message, not the C_Timer.After one... :confused:

Seerah 02-03-20 01:45 PM

What is your code now?

Fizzlemizz 02-03-20 05:34 PM

Requires a hardware event for certain channels now.
https://wow.gamepedia.com/API_SendChatMessage

Nodos7 02-04-20 11:02 AM

Quote:

Originally Posted by Seerah (Post 335075)
What is your code now?

I tried a lot variations, but they all are not worked. Sorry, i'm really noob at addons.

This code not working:
Code:

function ButtonHelp_OnClick()
    SendChatMessage("Help me!");
    C_Timer.After(3, function () SendChatMessage("Somebody, help!") end);
end

XML code:
Code:

<Button name="ButtonHelp" inherits="UIPanelButtonTemplate" text="Help Button">
        <Size>
        <AbsDimension x="50" y="23" />
        </Size>
                <Anchors>
                        <Anchor point="TOPLEFT">
                                <Offset x="300" y="0" />
                        </Anchor>
                </Anchors>
                        <Scripts>
                                <OnClick>
                                        ButtonHelp_OnClick();
                                </OnClick>
                        </Scripts>
</Button>

I just want to run this macro as addon and make special button for it:
Code:

/say Help me!
/in 3 /say I need help!


Fizzlemizz 02-04-20 01:46 PM

If you can't do it as a macro because the hardware event is required for the second /say or the /in is seemingly being swallowed, you won't be able to do it as an addon.


All times are GMT -6. The time now is 04:33 PM.

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