I'm basically trying to create a script that'll cast buffs when triggered by a chat event. I'm only passingly familiar with scripting, pretty much just proficient enough to mod other people's scripts, so I thought I'd try to modify the dAFK script. I tried to simply replace the "SendChatMessage" command on an if/then statement with a simple CastSpellByName(""); command and it doesn't seem to be working.
The full addon is here
http://www.curse.com/addons/rom/dafk
I was chaging the original code here:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
function dAFK.SendAutoReply(event, channel) local whereToSend = {
CHAT_MSG_WHISPER = { StringTable = "Wisper", Type = "WHISPER", Channel = arg4, RunCheck = function () return channel ~= nil end, },
CHAT_MSG_GUILD = { StringTable = "Guild", Type = "GUILD", Channel = nil, RunCheck = function () return true end, },
CHAT_MSG_PARTY = { StringTable = "Party", Type = "PARTY", Channel = nil, RunCheck = function () return dAFK.DNDInParty end, }, }
local messageMap = { [1] = "AutoReplyAFK", [2] = "AutoReplyDND",
[3] = "AFK", [4] = "DND", }
local messageMapFn = function (event)
return ((dAFK.UserMessage == 1 and dAFK.UserMessages[messageMap[(dAFK.State + 2)]] ~= nil and dAFK.UserMessages[messageMap[(dAFK.State + 2)]] ~= "")
and dAFK.UserMessages[messageMap[(dAFK.State + 2)]]
or dAFK.Strings[whereToSend[event].StringTable][messageMap[(dAFK.State)]]);
end;
if (whereToSend[event].RunCheck()) then
SendChatMessage(dAFK.Strings.AutoReply.." "..messageMapFn(event), whereToSend[event].Type, 0, whereToSend[event].Channel);
else
PlaySoundByPath("Interface/Addons/dAFK/Sounds/Notify.wav");
end;
end;
|
to
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
function dAFK.SendAutoReply(event, channel) local whereToSend = {
CHAT_MSG_WHISPER = { StringTable = "Wisper", Type = "WHISPER", Channel = arg4, RunCheck = function () return channel ~= nil end, },
CHAT_MSG_GUILD = { StringTable = "Guild", Type = "GUILD", Channel = nil, RunCheck = function () return true end, },
CHAT_MSG_PARTY = { StringTable = "Party", Type = "PARTY", Channel = nil, RunCheck = function () return dAFK.DNDInParty end, }, }
local messageMap = { [1] = "AutoReplyAFK", [2] = "AutoReplyDND",
[3] = "AFK", [4] = "DND", }
local messageMapFn = function (event)
return ((dAFK.UserMessage == 1 and dAFK.UserMessages[messageMap[(dAFK.State + 2)]] ~= nil and dAFK.UserMessages[messageMap[(dAFK.State + 2)]] ~= "")
and dAFK.UserMessages[messageMap[(dAFK.State + 2)]]
or dAFK.Strings[whereToSend[event].StringTable][messageMap[(dAFK.State)]]);
end;
if (whereToSend[event].RunCheck()) then
CastSpellByName("Mysterious Grace");
else
CastSpellByName("Mysterious Grace");
end;
end;
|
The only part I've changed (and broken) is what's supposed to happen on the event trigger. Ideally instead of replying with "I'm afk" in whisper or in guild, I wanted it to simply cast the buff. Simplistic I know... but I'm not really skilled enough with code to do much better. The /afk command still triggers the "I 'm going afk" message in guild chat, but nothing happens when my toon is whispered or my toon's name is mentioned.
I'll try out different things in the meantime, but any help, tips, or a new script entirely would be greatly appreciated.