
NytFall Alpha rev1
By: a guest on Feb 23rd, 2010 | syntax:
Lua | size: 1.58 KB | hits: 63 | expires: Never
--[[
NytFall.
Currently:
Displays a message when logging in.
Prints a message if you fail to move in a raid.
At the end of combat, sends a list of all people who failed to raid or party.
]]
-- Frames
NytFall = CreateFrame("Frame", "NytFall")
LibFail = LibStub("LibFail-1.0")
local Fails = LibFail:GetSupportedEvents()
local CombatFails = {} -- We'll use this to record fails and report at the end of combat
-- Register
NytFall:RegisterEvent("PLAYER_ENTERING_WORLD")
NytFall:RegisterEvent("PLAYER_REGEN_ENABLED")
-- Main Funcs
function NytFall_OnEvent(self, event, ...)
if (event == "PLAYER_ENTERING_WORLD") then
DEFAULT_CHAT_FRAME:AddMessage("NytFall BETA loaded.")
elseif (event == "PLAYER_REGEN_ENABLED") then
if (#CombatFails ~= 0) then
for k, v in pairs(CombatFails) do
if (UnitInRaid("player") == true) then
SendChatMessage(v, "RAID")
else
SendChatMessage(v, "PARTY")
end
end
end
end
end
local function NytFall_OnFail(event, player, type)
local FailSpell = GetSpellInfo(LibFail:GetEventSpellId(event)) or "" -- Get the spell that killed the player
local LibFail_Message
local Count
if (type == LibFail.FAIL_TYPE_NOTMOVING) then
LibFail_Message = "%s did not move from %s!"
CombatFails[player] = LibFail_Message
end
print(LibFail_Message:format(player, spell)) -- Replace the first $s with the playername and %s with the Spell name
end
-- Other
for _, event in ipairs(Fails) do
LibFail.RegisterCallback("NytFall", event, "NytFall_OnFail")
end
NytFall:SetScript("OnEvent", "NytFall_OnEvent")