|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
local GuildAutoInvite = {}
_G.GuildAutoInvite = GuildAutoInvite
local frame=_G.GuildAutoInvite_Frame
function GuildAutoInvite_OnLoad(frame)
frame:RegisterEvent("CHAT_MSG_WHISPER")
end
function GuildAutoInvite:OnEvent(event, frame)
if (event=="CHAT_MSG_WHISPER") then
if (arg1=="inviteme") then
GuildInvite(arg4);
end
end
end
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 |
<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">
<Frame name="GuildAutoInvite_Frame">
<Scripts>
<OnEvent>
GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
</OnEvent>
</Scripts>
</Frame>
</Ui>
|
Quoted from "potato221;495268"
Hello all,
I'm trying to create my first addon, one where if a player whispers you a certain phrase they get an invite to the guild. My end goal is to have a basic UI where you can turn it on and off, and change the phrase that you need to be whispered. For now though, I'm just trying to get it to work with a predefined phrase in the code and it's always on. This is what I have in my lua:
[highlight]...snip...[/highlight]
I honestly have almost no clue how to do this, and this is as far as I've been able to get using online tutorials and what little C I know. Can anyone help me get this functional?
Thank you
|
|
Source code |
1 |
GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) |
|
|
Source code |
1 |
function GuildAutoInvite:OnEvent(event, frame) |
|
|
Source code |
1 2 3 4 5 6 7 |
function GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
if (event=="CHAT_MSG_WHISPER") then
if (arg1=="inviteme") then
--GuildInvite(arg4);
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper received, arg4 = "..(arg4 or "nil"))
end
end
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 |
<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">
<Frame name="GuildAutoInvite_Frame">
<Scripts>
<OnEvent>
GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
</OnEvent>
<OnLoad>
GuildAutoInvite_OnLoad(this)
</OnLoad>
</Scripts>
</Frame>
</Ui>
|
Quoted from "potato221;495385"
Ok, I see what I did wrong, but for some reason after I changed my lua and xml so it looks like what you posted, I get no chat message at all, where it looks like I should be getting the value of arg4 or the word nil.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
function GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
DEFAULT_CHAT_FRAME:AddMessage("OnEvent called, event was "..(event or "nil"))
if (event=="CHAT_MSG_WHISPER") then
DEFAULT_CHAT_FRAME:AddMessage("in first if, arg1 is "..(arg1 or "nil"))
if (arg1=="inviteme") then
--GuildInvite(arg4);
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper received, arg4 = "..(arg4 or "nil"))
end
end
end
|
|
|
Source code |
1 2 3 4 |
<OnEvent>
DEFAULT_CHAT_FRAME:AddMessage("in frame's OnEvent snippet. Relevant paarams are "..(event or "nil")..", "..(arg1 or "nil")..", "..(arg4 or "nil"))
GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
</OnEvent>
|
Quoted from "potato221;495513"
Yea, it's not being triggered at all, so I guess I need to find a new event to trigger it.
EDIT: I just took a look at GroupInvite and I see that they use that same event (CHAT_MSG_WHISPER). Not sure what I'm doing wrong.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
local GuildAutoInvite = {}_G.GuildAutoInvite = GuildAutoInvite
local frame=_G.GuildAutoInvite_Frame
function GuildAutoInvite_OnLoad(frame)
frame:RegisterEvent("CHAT_MSG_WHISPER_INFORM")
end
function GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
DEFAULT_CHAT_FRAME:AddMessage("OnEvent called, event was "..(event or "nil"))
if (event=="CHAT_MSG_WHISPER_INFORM") then
DEFAULT_CHAT_FRAME:AddMessage("in first if, arg1 is "..(arg1 or "nil"))
if (arg1=="ginvite") then
--GuildInvite(arg4);
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg1 or "nil1"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg2 or "nil2"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg3 or "nil3"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg4 or "nil4"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg5 or "nil5"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg6 or "nil6"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg7 or "nil7"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg8 or "nil8"))
DEFAULT_CHAT_FRAME:AddMessage("Invite whisper recieved, arg4= "..(arg9 or "nil9"))
end
end
end
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 |
<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd"> <Frame name="GuildAutoInvite_Frame">
<Scripts>
<OnEvent>
DEFAULT_CHAT_FRAME:AddMessage("in frame's OnEvent snippet. Relevant params are "..(event or "nil")..","..(arg1 or "nil")..","..(arg4 or "nil"))
GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
</OnEvent>
<OnLoad>
GuildAutoInvite_OnLoad(this)
</OnLoad>
</Scripts>
</Frame>
</Ui>
|
|
|
Source code |
1 |
local frame=_G.GuildAutoInvite_Frame |
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
SLASH_GetArguments1 = "/getargs"
SlashCmdList['GetArguments'] = function (ebox, msg)
-- Extract each space seperated argument from parameter list
local args = {}
local nextarg, idx, argcount
idx = 0
repeat
_, idx, nextarg = string.find((msg or ""), "([^%s]+)", idx+1)
-- Strip off any leading or trailing spaces, then add to argument table
if nextarg then
_, _, nextarg = string.find(nextarg, "^%s*(.-)%s*$")
args[#args+1] = nextarg
end
until (not idx)
-- Show all arguments given
for i = 1, #args do
DEFAULT_CHAT_FRAME:AddMessage("args['..i..'] = "..args[i])
end
end
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
local GuildAutoInvite = {}_G.GuildAutoInvite = GuildAutoInvite
local frame=_G.GuildAutoInvite_Frame
local words = {}
local disable = "false"
local phrase = "ginvite"
SLASH_Disable1 = "/GAI"
SLASH_Disable2 = "/gai"
SlashCmdList['Disable'] = function(editBox, msg)
words = {}
for arg in msg:gmatch("%a+")do
words[#words+1] = arg:lower();
end
if words[1] == "off" then
disable = "true"
DEFAULT_CHAT_FRAME:AddMessage("Guild Auto Invite turned off")
elseif words[1] == "on" then
disable = "false"
DEFAULT_CHAT_FRAME:AddMessage("Guild Auto Invite turned on")
elseif words[1] == "pass" then
phrase = words[2]
DEFAUL_CHAT_FRAME:AddMessage("Invite password changed to "..(phrase))
else
DEFAULT_CHAT_FRAME:AddMessage("Please specify on or off")
end
end
function GuildAutoInvite_OnLoad(frame)
frame:RegisterEvent("CHAT_MSG_WHISPER")
end
function GuildAutoInvite:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
if (disable=="false") then
if (event=="CHAT_MSG_WHISPER") then
if (arg1==phrase) then
GuildInvite(arg4);
end
end
end
end
|
Quoted from "Peryl;505589"
Your choice. I always used Public Domain, but I don't really care if people use my code.
Many use a Creative Commons (By-Nc-Sa 3.0), others use an MIT or MIT variant license. Your best bet is to go read the various licenses and pick the one you are comfortable with.