Quantcast

Just do the reward price highlighting here, no need to use the same even twice

p3lim [12-28-10 - 01:21]
Just do the reward price highlighting here, no need to use the same even twice
Filename
Automate.lua
Rewards.lua
diff --git a/Automate.lua b/Automate.lua
index 75ca9ad..5f6c73c 100644
--- a/Automate.lua
+++ b/Automate.lua
@@ -46,6 +46,18 @@ end)
 addon:Register('QUEST_COMPLETE', function(...)
 	if(GetNumQuestChoices() <= 1) then
 		GetQuestReward(QuestFrameRewardPanel.itemChoice)
+	elseif(GetNumQuestChoices() > 1) then
+		local bestValue, bestIndex = 0
+
+		for index = 1, GetNumQuestChoices() do
+			local item, _, _, _, _, _, _, _, _, _, value = GetItemInfo(GetQuestItemLink('choice', index))
+
+			if(value > bestValue) then
+				bestValue, bestIndex = value, index
+			end
+		end
+
+		QuestInfoItem_OnClick(_G['QuestInfoItem' .. bestIndex])
 	end
 end)

diff --git a/Rewards.lua b/Rewards.lua
deleted file mode 100644
index e39e70e..0000000
--- a/Rewards.lua
+++ /dev/null
@@ -1,18 +0,0 @@
-local addon = CreateFrame('Frame')
-addon:RegisterEvent('QUEST_COMPLETE')
-addon:SetScript('OnEvent', function()
-	local bestValue, bestIndex = 0
-
-	for index = 1, GetNumQuestChoices() do
-		local _, _, _, _, _, _, _, _, _, _, value = GetItemInfo(GetQuestItemLink('choice', index))
-		local _, _, quantity = GetQuestItemInfo('choice', index)
-
-		if(value and (value * (quantity or 1) > bestValue)) then
-			bestValue, bestIndex = value * (quantity or 1), index
-		end
-	end
-
-	if(bestIndex) then
-		QuestInfoItem_OnClick(_G['QuestInfoItem' .. bestIndex])
-	end
-end)