Quantcast

Very small cleanup build.

Matthew Cooney [07-05-11 - 08:22]
Very small cleanup build.
Filename
LightwellBuddy.toc
README
core.lua
diff --git a/LightwellBuddy.toc b/LightwellBuddy.toc
index 690e707..523c647 100644
--- a/LightwellBuddy.toc
+++ b/LightwellBuddy.toc
@@ -1,6 +1,6 @@
 ## Title: Lightwell Buddy
 ## Interface: 40200
-## Notes: Says a message when you summon a Lightwell and a random message when someone uses your Lightwell.
+## Notes: Says a random message when you summon a Lightwell and when someone uses your Lightwell.
 ## Version: @project-version@

 core.lua
\ No newline at end of file
diff --git a/README b/README
index 06038b7..59eb79e 100644
--- a/README
+++ b/README
@@ -7,6 +7,22 @@ To configure the AddOn, simply edit the core.lua file (in any text editor) as in
 Thanks to Hershe of Silver Hand US for the concept and for testing and fixing my initial version.

 ==Change Log==
+--v0.07--
+Very small cleanup build.
+
+Replaced the SAP_message and SUMMON_message variables with a single message variable to reflect Hershe's changes to GetMessage.
+
+--v0.06--
+Fixed several bugs that prevented the addon from sending messages:
+
+1. The GetMessage function was not recognizing the whichTable variable as a text string. As a consequence, the "If" conditions that attempted to determine which message table was being used in the GetMessage function were not working. These "if" conditions were removed.
+
+2. The destName variable was not being passed from the COMBAT_LOG_EVENT_UNFILTERED to the GetMessage function, causing the %u token to not be changed. destName was added as an argument to the GetMessage function.
+
+3. SAP_message and SUMMON_message were not being given a value by the GetMessage function. The SendChatMessage commands were giving nil messages, resulting in an error. The SAP_message and SUMMON_message variables were replaced with the message variable.
+
+4. In the SendChatMessage commands, conditions such as SAP_CHANNEL_TYPE == WHISPER were not determining properly. Quotes were added to recognize WHISPER and CHANNEL as a text string, i.e. SAP_CHANNEL_TYPE == "WHISPER".
+
 --v0.05--
 Split many of the existing configuration constants into two separate constants, one for SPELL_AURA_APPLIED events and the other for SPELL_SUMMON events.

diff --git a/core.lua b/core.lua
index 642e7bb..27c50f9 100644
--- a/core.lua
+++ b/core.lua
@@ -20,7 +20,7 @@ When typed without quotation marks, the uppercase english name for all channel t
 "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.
 WHISPER will send the message as a whisper to the user of the Lightwell. This won't work properly for your summon message.
 ]]
-local SAP_CHANNEL_TYPE = "SMART"
+local SAP_CHANNEL_TYPE = "WHISPER"
 local SUMMON_CHANNEL_TYPE = "SMART"


@@ -85,7 +85,7 @@ local SUMMON_PHRASES = {
 	--Start of table
 	[1] = "Click my Lightwell for a SURPRISE!",

-	--End of tabke
+	--End of table
 }


@@ -107,15 +107,14 @@ local RENEW_SPELLID = 7001
 local charges_used = 0
 local charges_remaining = 0

-local SAP_message;
-local SUMMON_message;
+local message;

 local random = random
 local gsub = string.gsub
 local SendChatMessgae = SendChatMessage


-local function GetMessage(message, whichTable)
+local function GetMessage(whichTable, destName)
 	message = nil --reset the message

 	repeat --keep trying to pick a random message until we get one
@@ -127,14 +126,14 @@ local function GetMessage(message, whichTable)
 			return PLAYER_NAME
 		elseif arg == "%c" then
 			return charges_remaining
-		elseif whichTable == SAP_PHRASES then --Only substitute destName/charges_used if the message is for a SPELL_AURA_APPLIED event.
-			if	arg == "%u" then
-				return destName
-			elseif arg == "%x" then
-				return charges_used
-			end
+		elseif arg == "%u" then
+			return destName
+		elseif arg == "%x" then
+			return charges_used
+
 		end
 	end)
+
 end

 local function resetCharges()
@@ -159,19 +158,19 @@ function LWB_events:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, so
 	if event == "SPELL_SUMMON" and sourceGUID == PLAYER_GUID and spellId == LIGHTWELL_SPELLID then
 		resetCharges()

-		GetMessage(SUMMON_message, SUMMON_PHRASES)
+		GetMessage(SUMMON_PHRASES, destName)

 		if random(SUMMON_CHANCE) == 1 then
-		  SendChatMessage(SUMMON_message, SUMMON_CHANNEL_TYPE == "SMART" and ((GetNumRaidMembers() > 0 and RAID) or (GetNumPartyMembers() > 0 and PARTY) or (SAY)) or SUMMON_CHANNEL_TYPE, SUMMON_LANGUAGE, (SUMMON_CHANNEL_TYPE == CHANNEL and SUMMON_CHANNEL_NUMBER) or nil)
+		  SendChatMessage(message, SUMMON_CHANNEL_TYPE == "SMART" and ((GetNumRaidMembers() > 0 and RAID) or (GetNumPartyMembers() > 0 and PARTY) or (SAY)) or SUMMON_CHANNEL_TYPE, SUMMON_LANGUAGE, (SUMMON_CHANNEL_TYPE == "CHANNEL" and SUMMON_CHANNEL_NUMBER) or nil)
 		end
 	elseif event == "SPELL_AURA_APPLIED" and sourceGUID == PLAYER_GUID and spellId == RENEW_SPELLID then
 		charges_remaining = charges_remaining - 1
 		charges_used = charges_used + 1

-		GetMessage(SAP_message, SAP_PHRASES)
+		GetMessage(SAP_PHRASES, destName)

 		if random(SAP_CHANCE) == 1 then
-			SendChatMessage(SAP_message, SAP_CHANNEL_TYPE == "SMART" and ((GetNumRaidMembers() > 0 and RAID) or (GetNumPartyMembers() > 0 and PARTY) or (SAY)) or SAP_CHANNEL_TYPE, SAP_LANGUAGE, (SAP_CHANNEL_TYPE == WHISPER and destName) or (SAP_CHANNEL_TYPE == CHANNEL and SAP_CHANNEL_NUMBER) or nil)
+			SendChatMessage(message, SAP_CHANNEL_TYPE == "SMART" and ((GetNumRaidMembers() > 0 and RAID) or (GetNumPartyMembers() > 0 and PARTY) or (SAY)) or SAP_CHANNEL_TYPE, SAP_LANGUAGE, (SAP_CHANNEL_TYPE == "WHISPER" and destName) or (SAP_CHANNEL_TYPE == "CHANNEL" and SAP_CHANNEL_NUMBER) or nil)
 		end
 	end
 end