I'm learning LUA for wow addon's and it say's to look at samples so I downloaded a very simple addon and looked at the code this was it:
Code:
local frame = CreateFrame("FRAME");
frame:RegisterEvent("ADDON_LOADED");
frame:RegisterEvent("DUEL_REQUESTED");
function frame:print(msg)
DEFAULT_CHAT_FRAME:AddMessage(msg)
end
function frame:OnEvent(event, arg1)
if event == "ADDON_LOADED" and arg1 == "DuelCancel" then
if duelcancelbool == nil then
duelcancelbool = "on";
end
elseif event == "DUEL_REQUESTED" then
if duelcancelbool == "on" then
CancelDuel();
end
end
end
frame:SetScript("OnEvent", frame.OnEvent);
SLASH_DUELCANCEL1 = "/duelcancel";
function SlashCmdList.DUELCANCEL(msg)
if msg ~= nil then
msg = string.lower(msg);
end
if msg == "on" then
print("DuelCancel: on");
duelcancelbool = "on";
elseif msg == "off" then
print("DuelCancel: off");
duelcancelbool = "off";
else
if duelcancelbool == "on" then
print("DuelCancel: ".. duelcancelbool);
else
print("DuelCancel: ".. duelcancelbool);
end
print("Type /duelcancel off or on to change");
end
end
Let me type out what I believe its does.
Assigns a local variable called frame which is equal to CreateFrame("FRAME")
Then it tells the frame variable to register a event when the addon is loaded and also an event when a duel is requested.
Then it creates a function called frame
rint(msg) .... ? that tells DEFAULT_CHAT_FRAME to add a message with the msg variable? and thats where I get confused...
what assigns the "msg" variable? why is the function named "frame
rint(msg)"? I tried reading the wow api pages on wow wiki but holy shit.. that just sends me everywhere... something that would help me alot would be if you could tell me what the : after the variable does I went threw the entire LUA handbook and didn't find anything there about the colon... this is a simple addon and I don't understand it ... +rep for help... even links are good to get me started. I watched a whole video on lua tutorial and read the handbook.