How to trigger events by chat?
I'm trying to learn a bit of lua in my free time and I got a little stuck. I want to make a code that can read what other players say in chatbox in the SAY channel, and if it matches a command, then execute the script for that command.
For example: player1 says "hello world" player2 has lua script and when player1 says "hello world", executes a script that makes player2 say "hi" Sort of like auto responding to certain things. Can someone please give me a small example of this to go by? |
You would have to watch events triggering like CHAT_MSG_SAY, CHAT_MSG_WHISPER etc which are listed on http://wowprogramming.com/docs/events and http://www.wowpedia.org/Events/Communication
The latter gives a brief explanation as to how you would go about using them with an xml based addon. |
idk..
Can you give me a small example of how to use them? o_O I'm still not getting it. I just need to figure out how to like.. make it read certain things.. like..
if msg = x then execute y if msg does NOT = x then do nothing how would i do that? |
lua Code:
|
omg thanks! works like a charm! There's only one small issue.
How would I modify that code so that when I say "hello world" it does nothing, but when other people say "hello world" it executes the script? Also, when it executes, it makes me say "hi" twice. That's the only issue I'm having now. I really appreciate all the help. :D I think it would be something like this, but i can't seem to find the variable to define yourself: Code:
local frame=CreateFrame("frame"); |
UnitName(unitToken) is what you're looking for:
Code:
local myName = UnitName("player") |
All times are GMT -6. The time now is 12:58 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI