WoWInterface SVN LastWords

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

LastWords_Critters.lua File deleted
readme.txt
16,11 → 16,8
Three commands are provided:
 
/lastwords reset
Resets the addon, clearing any added critters (using /lastwords add) and returning the running totals for all critters to 0.
Resets the addon returning the running totals for all critters to 0.
 
/lastwords add
Adds your current target to the list of "critters".
 
/lastwords report
Outputs a list of the critters you have brutally massacred to the default chat frame.
 
LastWords.lua
1,18 → 1,73
function LastWords_OnEvent()
local LW_Ver = 2.0
local LW_Compat = 2.0
 
function Initialise_LastWord_Options()
lastwords_options = {}
lastwords_options =
{
["debug"] = false,
["collect"] = true,
["critters"] = {},
["version"] = LW_Ver
}
end
 
function LastWords_OnEvent(event, ...)
if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
if (arg2=="PARTY_KILL") and (arg3==UnitGUID("player")) then
if lastwords_options[arg7]~=nil then
local timestamp, combatevent, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = ...
if (combatevent=="PARTY_KILL") and (sourceGUID==UnitGUID("player")) then
if lastwords_options["critters"][destName]~=nil or lastwords_critters[destGUID] then
local iFLW = random(#(LastWords_FLW));
local LW_Message = LastWords_FLW[iFLW]
LW_Message = gsub(LW_Message, "#n", (UnitName("player")))
LW_Message = gsub(LW_Message, "#c", (UnitClass("player")))
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800"..arg7.." said:|r "..LW_Message);
lastwords_options[arg7] = lastwords_options[arg7] + 1
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800"..destName.." said:|r "..LW_Message);
if lastwords_options["critters"][destName] == nil then
lastwords_options["critters"][destName] = 1
else
lastwords_options["critters"][destName] = lastwords_options["critters"][destName] + 1
end
end
end
elseif (event=="UPDATE_MOUSEOVER_UNIT") then
LW_AddCreature("mouseover")
elseif (event=="PLAYER_FOCUS_CHANGED") then
LW_AddCreature("focus")
elseif (event=="UNIT_TARGET") then
local unitname = ...
LW_AddCreature(unitname.."target")
elseif (event=="VARIABLES_LOADED") then
DEFAULT_CHAT_FRAME:AddMessage("test")
if lastwords_options == nil then
Initialise_LastWord_Options();
end
 
if lastwords_options["version"] == nil or lastwords_options["version"] < LW_Compat then
Initialise_LastWord_Options();
end
 
LWFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
 
if lastwords_options["collect"] == true then
LWFrame:RegisterEvent("UPDATE_MOUSEOVER_UNIT");
LWFrame:RegisterEvent("UNIT_TARGET");
lastwords_critters = {}
end
 
SLASH_LASTWORDS1 = "/lastwords"
SLASH_LASTWORDS2 = "/lw"
SlashCmdList["LASTWORDS"] = LastWords_Command;
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800Last Words Loaded Successfully!|r");
end
end
 
function LW_AddCreature(creature)
if UnitCreatureType(creature) == "Critter" and lastwords_options["critters"][(UnitName(creature))] == nil then
local lwguid = UnitGUID(creature)
lastwords_critters[lwguid] = true
end
end
 
function LastWords_Command(cmd)
local tbl = {}
for v in string.gmatch(cmd, "[^ ]+") do
21,17 → 76,17
if tbl[1] == "reset" then
Initialise_LastWord_Options();
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800Last Words Reset Successfully!|r");
elseif tbl[1] == "add" then
if (UnitName("target")) ~=nil then
lastwords_options[(UnitName("target"))] = 0;
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800"..(UnitName("target")).." added.|r");
else
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800".."You need to target the critter you wish to add!|r");
end
--elseif tbl[1] == "add" then
-- if (UnitName("target")) ~=nil then
-- lastwords_options[(UnitName("target"))] = 0;
-- DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800"..(UnitName("target")).." added.|r");
-- else
-- DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800".."You need to target the critter you wish to add!|r");
-- end
elseif tbl[1] == "report" then
local output
output = ""
for index,value in pairs(lastwords_options) do
for index,value in pairs(lastwords_options["critters"]) do
if value ~= 0 then
if value ==1 then
output = output..value.." "..index..", ";
60,26 → 115,12
else
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800Last Words accepts the following commands:|r")
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800reset:|r Resets all options to their default values.")
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800add:|r Adds your current target to the list of critters.")
--DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800add:|r Adds your current target to the list of critters.")
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800report:|r Sends a list of the critters you have slaughtered to the chat frame.")
end
end
 
if lastwords_options == nil then
Initialise_LastWord_Options();
end
 
local frame = CreateFrame("Frame", "MyAddOnFrame");
frame:SetScript("OnEvent", LastWords_OnEvent);
frame:SetScript("OnLoad", LastWords_OnLoad);
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
 
SLASH_LASTWORDS1 = "/lastwords"
SLASH_LASTWORDS2 = "/lw"
SlashCmdList["LASTWORDS"] = LastWords_Command;
 
 
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800Last Words Loaded Successfully!|r");
 
 
 
local frame = CreateFrame("Frame", "LWFrame");
frame:SetScript("OnEvent", function(self, event, ...) LastWords_OnEvent(event, ...) end);
frame:RegisterEvent("VARIABLES_LOADED");
DEFAULT_CHAT_FRAME:AddMessage("testy")
\ No newline at end of file