From ff9d1be1a2b524cfc789db2d976190e74c59acb1 Mon Sep 17 00:00:00 2001 From: Matthew Cooney Date: Tue, 28 Jun 2011 16:48:36 +1000 Subject: [PATCH] Hershe's second fix --- core.lua | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/core.lua b/core.lua index a1b152f..3cc47e5 100644 --- a/core.lua +++ b/core.lua @@ -17,8 +17,8 @@ local SendChatMessgae = SendChatMessage local LWB_phrases = { --[[ Format: - [#] = "Phrase", - [#] = "Phrase", + [#] = "Phrase", + [#] = "Phrase", Any occurrence of %u in the phrase will be replaced with the Lightwell user's name, any of %p will be replaced with your name. Put a double dash ( -- ) at the start of a line in this table to "comment" it and stop LWB from using that phrase. @@ -26,39 +26,43 @@ To use the \ (backslash) or | (vertical bar) characters in the phrase, you may n ]] --Start of table - [1] = "Thank you for using the Lightwell %u!", - [2] = "May the Light bless you %u.", - - + [1] = "Thank you for using the Lightwell %u!", + [2] = "May the Light bless you %u.", + + --End of table } function LWB_events:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellId, spellName, spellSchool, ...) + if not PLAYER_GUID then + PLAYER_GUID = UnitGUID("player") + end + + if event == "SPELL_AURA_APPLIED" and sourceGUID == PLAYER_GUID and spellId == RENEW_SPELLID then + message = nil --reset the message + + repeat --keep trying to pick a random message until we get one + message = LWB_phrases[random(#LWB_phrases)] or nil + until message - if event == "SPELL_AURA_APPLIED" and sourceGUID == PLAYER_GUID and spellId == RENEW_SPELLID then - message = nil --reset the message - - repeat --keep trying to pick a random message until we get one - message = LWB_phrases[random(#LWB_phrases)] or nil - until message - - message = gsub(message, "(%%[pu])", function(arg) - if arg == "%p" then - return PLAYER_NAME - else - return destName + message = gsub(message, "(%%[pu])", function(arg) + if arg == "%p" then + return PLAYER_NAME + else + return destName + end + end) + + SendChatMessgae(message, SAY, nil, nil) --Say the message. DO NOT CHANGE THE message ARGUMENT. + --[[ + To change how the message is said (e.g. language, channel), visit this page: + http://www.wowpedia.org/API_SendChatMessage + ]] end - end) - SendChatMessgae(message, SAY, nil, nil) --Say the message. DO NOT CHANGE THE message ARGUMENT. - --[[ - To change how the message is said (e.g. language, channel), visit this page: - http://www.wowpedia.org/API_SendChatMessage - ]] - end end LWB_frame:SetScript("OnEvent", function(self, event, ...) - LWB_events[event](self, ...) + LWB_events[event](self, ...) end) \ No newline at end of file -- 1.7.9.5