Quantcast

Use a database for lockboxes instead of the (faulty) localization hack.

Adrian L Lange [07-13-12 - 02:53]
Use a database for lockboxes instead of the (faulty) localization hack.
Filename
Lockpicking.lua
Molinari.lua
Molinari.toc
diff --git a/Lockpicking.lua b/Lockpicking.lua
new file mode 100644
index 0000000..d569198
--- /dev/null
+++ b/Lockpicking.lua
@@ -0,0 +1,37 @@
+local _, ns = ...
+
+local openable = {
+	['68729'] = true, -- MoP
+	['63349'] = true, -- MoP
+	['45986'] = true,
+	['43624'] = true,
+	['43622'] = true,
+	['43575'] = true,
+	['31952'] = true,
+	['12033'] = true,
+	['29569'] = true,
+	['5760'] = true,
+	['13918'] = true,
+	['5759'] = true,
+	['5758'] = true,
+	['13875'] = true,
+	['4638'] = true,
+	['16884'] = true,
+	['4637'] = true,
+	['4636'] = true,
+	['6355'] = true,
+	['16883'] = true,
+	['4634'] = true,
+	['4633'] = true,
+	['6354'] = true,
+	['16882'] = true,
+	['4632'] = true,
+	['88165'] = true,
+	['88567'] = true,
+	['88165'] = true,
+	['88567'] = true,
+}
+
+function ns.Openable(link)
+	return openable[link:match('item:(%d+)')]
+end
diff --git a/Molinari.lua b/Molinari.lua
index fd45757..e59e876 100644
--- a/Molinari.lua
+++ b/Molinari.lua
@@ -29,8 +29,7 @@ function button:PLAYER_LOGIN()
 	end

 	if(IsSpellKnown(1804)) then
-		-- Commence localization hack
-		rogue = ITEM_MIN_SKILL:gsub('%%s', (GetSpellInfo(1810))):gsub('%%d', '%(.*%)')
+		rogue = true
 	end

 	GameTooltip:HookScript('OnTooltipSetItem', function(self)
@@ -38,18 +37,18 @@ function button:PLAYER_LOGIN()
 		if(item and not InCombatLockdown() and IsAltKeyDown() and not (AuctionFrame and AuctionFrame:IsShown())) then
 			local spell, r, g, b = ScanTooltip(self, spells)

-			if(not spell and disenchanter and ns.Disenchantable(link)) then
-				spell, r, g, b = GetSpellInfo(13262), 1/2, 1/2, 1
-			elseif(not spell and rogue) then
-				for index = 1, self:NumLines() do
-					if(string.match(_G['GameTooltipTextLeft' .. index]:GetText() or '', rogue)) then
-						spell, r, g, b = GetSpellInfo(1804), 0, 1, 1
-					end
+			if(not spell) then
+				if(disenchanter and ns.Disenchantable(link)) then
+					spell, r, g, b = GetSpellInfo(13262), 1/2, 1/2, 1
+				elseif(rogue and ns.Openable) then
+					spell, r, g, b = GetSpellInfo(1804), 0, 1, 1
+				else
+					return
 				end
 			end

 			local bag, slot = GetMouseFocus():GetParent(), GetMouseFocus()
-			if(spell and GetContainerItemLink(bag:GetID(), slot:GetID()) == link) then
+			if(GetContainerItemLink(bag:GetID(), slot:GetID()) == link) then
 				button:SetAttribute('macrotext', string.format('/cast %s\n/use %s %s', spell, bag:GetID(), slot:GetID()))
 				button:SetAllPoints(slot)
 				button:Show()
diff --git a/Molinari.toc b/Molinari.toc
index f90cb92..8cf5291 100644
--- a/Molinari.toc
+++ b/Molinari.toc
@@ -6,3 +6,4 @@

 Molinari.lua
 Disenchanting.lua
+Lockpicking.lua