⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 informant.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
--[[	Informant	An addon for World of Warcraft that shows pertinent information about	an item in a tooltip when you hover over the item in the game.	3.5.0.0912 (Platypus)	$Id: Informant.lua 912 2006-06-26 13:53:44Z mentalpower $	License:		This program is free software; you can redistribute it and/or		modify it under the terms of the GNU General Public License		as published by the Free Software Foundation; either version 2		of the License, or (at your option) any later version.		This program is distributed in the hope that it will be useful,		but WITHOUT ANY WARRANTY; without even the implied warranty of		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the		GNU General Public License for more details.		You should have received a copy of the GNU General Public License		along with this program(see GLP.txt); if not, write to the Free Software		Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.--]]INFORMANT_VERSION = "3.5.0.0912"if (INFORMANT_VERSION == "<".."%version%>") then	INFORMANT_VERSION = "3.7.DEV"end-- GLOBAL FUNCTION PROTOTYPES:local getItem--(itemID);     itemID is the first value in a blizzard hyperlink id--                           this pattern would extract the id you need:--                             "item:(%d+):%d+:%d+:%d+"-- LOCAL FUNCTION PROTOTYPES:local addLine				-- addLine(text, color)local clear					-- clear()local frameActive			-- frameActive(isActive)local frameLoaded			-- frameLoaded()local getCatName			-- getCatName(catID)local getFilter				-- getFilter(filter)local getFilterVal			-- getFilterVal(type)local getItem				-- getItem(itemID)local getRowCount			-- getRowCount()local nilSafeString			-- nilSafeString(String)local onEvent				-- onEvent(event)local onLoad				-- onLoad()local onVariablesLoaded		-- onVariablesLoaded()local onQuit				-- onQuit()local scrollUpdate			-- scrollUpdate(offset)local setDatabase			-- setDatabase(database)local setFilter				-- setFilter(key, value)local setFilterDefaults		-- setFilterDefaults()local setRequirements		-- setRequirements(requirements)local setSkills				-- setSkills(skills)local setVendors			-- setVendors(vendors)local showHideInfo			-- showHideInfo()local skillToName			-- skillToName(userSkill)local split					-- split(str, at)local tooltipHandler		-- tooltipHandler(funcVars, retVal, frame, name, link, quality, count, price)local getKeyBindProfile		-- getKeyBindProfile()local whitespace			-- whitespace(length)-- LOCAL VARIABLESlocal self = {}local lines = {}local itemInfo = nil-- GLOBAL VARIABLESBINDING_HEADER_INFORMANT_HEADER = _INFM('BindingHeader')BINDING_NAME_INFORMANT_POPUPDOWN = _INFM('BindingTitle')InformantConfig = {}-- LOCAL DEFINESCLASS_TO_CATEGORY_MAP = {	[2]  = 1,	[4]  = 2,	[1]  = 3,	[0]  = 4,	[7]  = 5,	[6]  = 6,	[11] = 7,	[9]  = 8,	[5]  = 9,	[15] = 10,}local filterDefaults = {		['all'] = 'on',		['embed'] = 'off',		['locale'] = 'default',		['show-vendor'] = 'on',		['show-vendor-buy'] = 'on',		['show-vendor-sell'] = 'on',		['show-usage'] = 'on',		['show-stack'] = 'on',		['show-merchant'] = 'on',		['show-quest'] = 'on',		['show-icon'] = 'on',	}-- FUNCTION DEFINITIONSfunction split(str, at)	local splut = {}	if (type(str) ~= "string") then return nil end	if (not str) then str = "" end	if (not at)		then table.insert(splut, str)	else		for n, c in string.gfind(str, '([^%'..at..']*)(%'..at..'?)') do			table.insert(splut, n)			if (c == '') then break end		end	end	return splutendfunction skillToName(userSkill)	local skillName = self.skills[tonumber(userSkill)]	local localized = "Unknown"	if (skillName) then		if (_INFM("Skill"..skillName)) then			localized = _INFM("Skill"..skillName)		else			localized = "Unknown:"..skillName		end	end	return localized, skillNameendfunction getItem(itemID)	local baseData = self.database[itemID]	if (not baseData) then 		return getItemBasic(itemID)	end	local _, _, _, iLevel, sType, _, iCount, _, sTexture = GetItemInfo(itemID)	local baseSplit = split(baseData, ":")	local buy = tonumber(baseSplit[1])	local sell = tonumber(baseSplit[2])	local class = tonumber(baseSplit[3])	local quality = tonumber(baseSplit[4])	local stack = tonumber(iCount) or tonumber(baseSplit[5])	local additional = baseSplit[6]	local usedby = baseSplit[7]	local quantity = baseSplit[8]	local limited = baseSplit[9]	local merchantlist = baseSplit[10]	local cat = CLASS_TO_CATEGORY_MAP[class]	local dataItem = {		['buy'] = buy,		['sell'] = sell,		['class'] = class,		['cat'] = cat,		['quality'] = quality,		['stack'] = stack,		['additional'] = additional,		['usedby'] = usedby,		['quantity'] = quantity,		['limited'] = limited,		['texture'] = sTexture,		['fullData'] = true,	}	local addition = ""	if (additional ~= "") then		addition = " - ".._INFM("Addit"..additional)	end	local catName = getCatName(cat)	if (not catName) then		if (sType) then			dataItem.classText = sType..addition		else			dataItem.classText = "Unknown"..addition		end	else		dataItem.classText = catName..addition	end	if (usedby ~= '') then		local usedList = split(usedby, ",")		local skillName, localized, localeString		local usage = ""		dataItem.usedList = {}		if (usedList) then			for pos, userSkill in pairs(usedList) do				localized = skillToName(userSkill)				if (usage == "") then					usage = localized				else					usage = usage .. ", " .. localized				end				table.insert(dataItem.usedList, localized)			end		end		dataItem.usageText = usage	end	local reqSkill = 0	local reqLevel = 0	local skillName = ""	local skillsRequired = self.requirements[itemID]	if (skillsRequired) then		local skillSplit = split(skillsRequired, ":")		reqSkill = skillSplit[1]		reqLevel = skillSplit[2]		skillName = skillToName(reqSkill)	end	dataItem.isPlayerMade = (reqSkill ~= 0)	dataItem.reqSkill = reqSkill	dataItem.reqSkillName = skillName	dataItem.reqLevel = iLevel or reqLevel	if (merchantlist ~= '') then		local merchList = split(merchantlist, ",")		local vendName		local vendList = {}		if (merchList) then			for pos, merchID in pairs(merchList) do				vendName = self.vendors[tonumber(merchID)]				if (vendName) then					table.insert(vendList, vendName)				end			end		end		dataItem.vendors = vendList	end	dataItem.quests = {}	dataItem.questCount = 0	local questItemUse = InformantQuests.usage[itemID]	if (questItemUse) then		local questData = split(questItemUse, ",")		local questInfoSplit, questID, questCount		for pos, questInfo in pairs(questData) do			questInfoSplit = split(questInfo, ":")			questID = tonumber(questInfoSplit[1])			questCount = tonumber(questInfoSplit[2])			if (not dataItem.quests[questID]) then				questName = Babylonian.GetString(InformantQuests.names, questID)				dataItem.quests[questID] = {					['count'] = questCount,					['name'] = questName,					['level'] = tonumber(InformantQuests.levels[questID])				}				dataItem.questCount = dataItem.questCount + 1			end		end	end	return dataItemendfunction getItemBasic(itemID)	if (not itemID) then return end	local sName, sLink, iQuality, iLevel, sType, sSubType, iCount, sEquipLoc, sTexture = GetItemInfo(tonumber(itemID))	if (sName) then		local dataItem = {			['classText'] = sType,			['quality'] = iQuality,			['stack'] = iCount,			['texture'] = sTexture,			['reqLevel'] = iLevel,			['fullData'] = false,		}	return dataItem	endendfunction setSkills(skills)	self.skills = skills	Informant.SetSkills = nil -- Set only onceendfunction setRequirements(requirements)	self.requirements = requirements	Informant.SetRequirements = nil -- Set only onceendfunction setVendors(vendors)	self.vendors = vendors	Informant.SetVendors = nil -- Set only onceendfunction setDatabase(database)	self.database = database	Informant.SetDatabase = nil -- Set only onceendfunction setFilter(key, value)	if (not InformantConfig.filters) then		InformantConfig.filters = {};		setFilterDefaults()	end	if (type(value) == "boolean") then		if (value) then			InformantConfig.filters[key] = 'on';		else			InformantConfig.filters[key] = 'off';		end	else		InformantConfig.filters[key] = value;	endendfunction getFilterVal(type)	if (not InformantConfig.filters) then		InformantConfig.filters = {}		setFilterDefaults()	end	return InformantConfig.filters[type]endfunction getFilter(filter)	value = getFilterVal(filter)	if ((value == _INFM('CmdOn')) or (value == "on")) then return true	elseif ((value == _INFM('CmdOff')) or (value == "off")) then return false end	return trueendfunction getLocale()	local locale = Informant.GetFilterVal('locale');	if (locale ~= 'on') and (locale ~= 'off') and (locale ~= 'default') then		return locale;	end	return GetLocale();endlocal categoriesfunction getCatName(catID)	if (not categories) then categories = {GetAuctionItemClasses()} end	for cat, name in categories do		if (cat == catID) then return name end	endendfunction tooltipHandler(funcVars, retVal, frame, name, link, quality, count, price)	-- nothing to do, if informant is disabled	if (not getFilter('all')) then		return;	end;	if EnhTooltip.LinkType(link) ~= "item" then return end	local quant = 0	local sell = 0	local buy = 0	local stacks = 1	local itemID, randomProp, enchant, uniqID, lame = EnhTooltip.BreakLink(link)	if (itemID and itemID > 0) and (Informant) then		itemInfo = getItem(itemID)	end	if (not itemInfo) then return end	itemInfo.itemName = name	itemInfo.itemLink = link	itemInfo.itemCount = count	itemInfo.itemQuality = quality	stacks = itemInfo.stack	if (not stacks) then stacks = 1 end	buy = tonumber(itemInfo.buy) or 0	sell = tonumber(itemInfo.sell) or 0	quant = tonumber(itemInfo.quantity) or 0	if (quant == 0) and (sell > 0) then		local ratio = buy / sell		if ((ratio > 3) and (ratio < 6)) then			quant = 1		else			ratio = buy / (sell * 5)			if ((ratio > 3) and (ratio < 6)) then				quant = 5			end		end	end	if (quant == 0) then quant = 1 end	buy = buy/quant	itemInfo.itemBuy = buy	itemInfo.itemSell = sell	itemInfo.itemQuant = quant	local embedded = getFilter('embed')	if (getFilter('show-icon')) then		if (itemInfo.texture) then			EnhTooltip.SetIcon(itemInfo.texture)		end	end	if (getFilter('show-vendor')) then		if ((buy > 0) or (sell > 0)) then			local bgsc = EnhTooltip.GetTextGSC(buy, true)			local sgsc = EnhTooltip.GetTextGSC(sell, true)			if (count and (count > 1)) then				if (getFilter('show-vendor-buy')) then					EnhTooltip.AddLine(string.format(_INFM('FrmtInfoBuymult'), count, bgsc), buy*count, embedded, true)					EnhTooltip.LineColor(0.8, 0.5, 0.1)				end				if (getFilter('show-vendor-sell')) then					EnhTooltip.AddLine(string.format(_INFM('FrmtInfoSellmult'), count, sgsc), sell*count, embedded, true)					EnhTooltip.LineColor(0.8, 0.5, 0.1)				end			else				if (getFilter('show-vendor-buy')) then					EnhTooltip.AddLine(string.format(_INFM('FrmtInfoBuy')), buy, embedded, true)					EnhTooltip.LineColor(0.8, 0.5, 0.1)				end				if (getFilter('show-vendor-sell')) then					EnhTooltip.AddLine(string.format(_INFM('FrmtInfoSell')), sell, embedded, true)					EnhTooltip.LineColor(0.8, 0.5, 0.1)				end			end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -