From 74461ef34ec21c78997b7caa8b502a23c491774a Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Fri, 15 Feb 2013 05:56:04 +0100 Subject: [PATCH] Make sure we're within the level range Fixes #7 --- Monomyth.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Monomyth.lua b/Monomyth.lua index f8fa3a0..472d426 100644 --- a/Monomyth.lua +++ b/Monomyth.lua @@ -252,6 +252,18 @@ local ignoredItems = { [29464] = true, -- Soothsayer's Runes } +local questTip = CreateFrame('GameTooltip', 'MonomythTip', UIParent) +local questLevel = string.gsub(ITEM_MIN_LEVEL, '%%d', '(%%d+)') + +local function GetQuestItemLevel() + for index = 1, questTip:NumLines() do + local level = string.match(_G['MonomythTipTextLeft' .. index]:GetText(), questLevel) + if(level and tonumber(level)) then + return tonumber(level) + end + end +end + local function BagUpdate(bag) if(not MonomythDB.items) then return end if(atBank or atMail or atMerchant) then return end @@ -259,7 +271,13 @@ local function BagUpdate(bag) for slot = 1, GetContainerNumSlots(bag) do local _, id, active = GetContainerItemQuestInfo(bag, slot) if(id and not active and not IsQuestFlaggedCompleted(id) and not ignoredItems[id]) then - UseContainerItem(bag, slot) + questTip:SetBagItem(bag, slot) + questTip:Show() + + local level = GetQuestItemLevel() + if(not level or level >= UnitLevel('player')) then + UseContainerItem(bag, slot) + end end end end -- 1.7.9.5