Quantcast

Hershe's Edit

Matthew Cooney [07-01-11 - 06:55]
Hershe's Edit
Filename
LightwellBuddy.toc
README
core.lua
diff --git a/LightwellBuddy.toc b/LightwellBuddy.toc
index dab3cbc..690e707 100644
--- a/LightwellBuddy.toc
+++ b/LightwellBuddy.toc
@@ -1,6 +1,6 @@
 ## Title: Lightwell Buddy
 ## Interface: 40200
-## Notes: Says a random message when someone uses your Lightwell.
+## Notes: Says a message when you summon a Lightwell and a random message when someone uses your Lightwell.
 ## Version: @project-version@

 core.lua
\ No newline at end of file
diff --git a/README b/README
index 722367f..223b601 100644
--- a/README
+++ b/README
@@ -4,4 +4,27 @@ http://www.wowinterface.com/forums/faq.php?faq=install#faq_howto_install

 To configure the AddOn, simply edit the core.lua file (in any text editor) as instructed.

-Thanks to Hershe of Silver Hand US for the concept and for testing and fixing my initial version.
\ No newline at end of file
+Thanks to Hershe of Silver Hand US for the concept and for testing and fixing my initial version.
+
+==Change Log==
+--v0.04 (Hershe's Edit)--
+-Summary-
+Added a summon message and the ability to put the number of used/remaining charges in messages.
+
+-Details-
+Added the MESSAGE_CHANNEL, MESSAGE_LANGUAGE, SUMMON_MESSAGE and SUMMON_CHANNEL constants.
+
+Added the charges_remaining and charges_used variables and the resetCharges function.
+
+Added the "SMART" channel value to use RAID, PARTY or SAY depending on your group status.
+
+Added the %c and %x tokens to the SPELL_AURA_APPLIED message to be replaced with charges_remaining and charges_used respectively.
+
+--v0.03--
+Added the sourceRaidFlags and destRaidFlags arguments to COMBAT_LOG)EVENT_UNFILTERED to fix for patch 4.2.
+
+Changed Interface to 40200.
+
+--v0.02 (Hershe's Second Fix)--
+
+The PLAYER_GUID constant wasn't being assigned correctly during the loading process. If not already assigned, it will be assigned on the first occurrence of COMBAT_LOG_EVENT_UNFILTERED.
diff --git a/core.lua b/core.lua
index fb0c3a8..f90c43e 100644
--- a/core.lua
+++ b/core.lua
@@ -1,68 +1,116 @@
-local ADDON_NAME, ns = ...
-
-local LWB_events = {}
-local LWB_frame = CreateFrame("Frame")
-LWB_frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
-
-local PLAYER_NAME = UnitName("player")
-local PLAYER_GUID = UnitGUID("player")
-local LIGHTWELL_SPELLID = 724
-local RENEW_SPELLID = 7001
-
-local message;
-
-local gsub = string.gsub
-local SendChatMessgae = SendChatMessage
-
-local LWB_phrases = {
---[[
-Format:
-	[#] = "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.
-To use the \ (backslash) or | (vertical bar) characters in the phrase, you may need to use \\ or || respectively.
-]]
-
-  --Start of table
-	[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, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, 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
-
-		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
-
-
-
-LWB_frame:SetScript("OnEvent", function(self, event, ...)
-	LWB_events[event](self, ...)
+--[[
+To change how the messages are said (e.g. language, channel), visit this page:
+	http://www.wowpedia.org/API_SendChatMessage
+]]
+
+--SELECT YOUR CHANNEL. You may enter the name of the channel you want your messages to go to (for example "SAY", "EMOTE", "PARTY", "RAID", "BATTLEGROUND", "GUILD", "OFFICER", or "SMART"). "SMART" will send the message to raid if you're in a raid, party if you're in a party, or say if you're in neither.
+local MESSAGE_CHANNEL = "SMART"
+
+--SELECT YOUR LANGUAGE. This is the language that all of your your messages will be sent in. e.g. "TROLL", "TAURAHE", "DWARVEN", "DRAENEI". nil uses your default language (Orcish for Horde, Common for Alliance)
+local MESSAGE_LANGUAGE = nil
+
+--ENTER LIGHTWELL SUMMON MESSAGE. Select a channel and enter a message to be displayed when you summon your lightwell.
+local SUMMON_MESSAGE = "Click my Lightwell for a SURPRISE!"
+local SUMMON_CHANNEL = "SMART"
+
+
+--[[Add Messages:
+Format:
+	[#] = "Phrase",
+	[#] = "Phrase",
+
+Any occurrence of the following placeholders will be replaced as follows:
+%u will be replaced by the Lightwell user's name.
+%p will be replace by your name.
+%c will be replaced by the number of charges remaining on the lightwell
+%x will be replaced by the number of charges used on the lightwell.
+
+Put a double dash ( -- ) at the start of a line in this table to "comment" it and stop LWB from using that phrase.
+To use the \ (backslash) or | (vertical bar) characters in the phrase, you may need to use \\ or || respectively.
+]]
+
+
+local LWB_phrases = {
+  --Start of table
+  [1] = "Thank you for using the Lightwell %u!",
+  [2] = "May the Light bless you %u.",
+
+  --End of table
+}
+
+--END OF CONFIGURATION. DO NOT MODIFY ANYTHING ELSE BELOW UNLESS YOU REALLY KNOW WHAT YOU'RE DOING!
+
+
+
+local ADDON_NAME, ns = ...
+
+local LWB_events = {}
+local LWB_frame = CreateFrame("Frame")
+LWB_frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
+
+local PLAYER_NAME = UnitName("player")
+local PLAYER_GUID = UnitGUID("player")
+local LIGHTWELL_SPELLID = 724
+local RENEW_SPELLID = 7001
+
+local charges_used = 0
+local charges_remaining = 0
+
+local message;
+
+local gsub = string.gsub
+local SendChatMessgae = SendChatMessage
+
+
+local function resetCharges()
+	charges_remaining = 10
+	charges_used = 0
+	for i = 7, NUM_GLYPH_SLOTS do
+ 		local enabled, glyphType, glyphTooltipIndex, glyphSpellID, icon = GetGlyphSocketInfo(i);
+ 		if ( enabled ) then
+   			if glyphSpellID == 55673 then
+				charges_remaining = 15
+			end
+		end
+	end
+end
+
+
+function LWB_events:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, ...)
+	if not PLAYER_GUID then
+		PLAYER_GUID = UnitGUID("player")
+	end
+
+	if event == "SPELL_SUMMON" and sourceGUID == PLAYER_GUID and spellId == LIGHTWELL_SPELLID then
+		resetCharges()
+		SendChatMessage(SUMMON_MESSAGE, SUMMON_CHANNEL == "SMART" and ((GetNumRaidMembers() > 0 and RAID) or (GetNumPartyMembers() > 0 and PARTY) or (SAY)) or SUMMON_CHANNEL, MESSAGE_LANGUAGE, nil)
+
+	elseif event == "SPELL_AURA_APPLIED" and sourceGUID == PLAYER_GUID and spellId == RENEW_SPELLID then
+		charges_remaining = charges_remaining - 1
+		charges_used = charges_used + 1
+		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, "(%%[pucx])", function(arg)
+			if arg == "%p" then
+				return PLAYER_NAME
+			elseif	arg == "%u" then
+				return destName
+			elseif arg == "%c" then
+				return charges_remaining
+			elseif arg == "%x" then
+				return charges_used
+			end
+		end)
+
+	SendChatMessage(message, MESSAGE_CHANNEL == "SMART" and ((GetNumRaidMembers() > 0 and RAID) or (GetNumPartyMembers() > 0 and PARTY) or (SAY)) or MESSAGE_CHANNEL, MESSAGE_LANGUAGE, (MESSAGE_CHANNEL == "WHISPER" and destName) or nil) --Say the message. DO NOT CHANGE THE message ARGUMENT.
+	end
+end
+
+
+LWB_frame:SetScript("OnEvent", function(self, event, ...)
+	LWB_events[event](self, ...)
 end)
\ No newline at end of file