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

📄 aucutil.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
--[[	Auctioneer Addon for World of Warcraft(tm).	Version: 3.5.0.0917 (Platypus)	Revision: $Id: AucUtil.lua 887 2006-06-02 18:25:21Z mentalpower $	Auctioneer utility functions.	Functions to maniuplate items keys, signatures etc	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 GPL.txt); if not, write to the Free Software		Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.]]--Local function prototypeslocal getTimeLeftString, getSecondsLeftString, getGSC, getTextGSC, nilSafeString, colorTextWhite, getWarnColor, nullSafe, sanifyAHSnapshot, getAuctionKey, getOppositeKey, getNeutralKey, getHomeKey, isValidAlso, breakItemKey, split, findClass, getCatName, getCatNumberByName, getCatForKey, getKeyFromSig, getCatForSig, getItemLinks, getItems, getItemHyperlinks, loadCategories, loadCategoryClasses, loadCategorySubClasses, chatPrint, setFilterDefaults, protectAuctionFrame, priceForOne, round, delocalizeFilterVal, localizeFilterVal, getLocalizedFilterVal, delocalizeCommand, localizeCommand, findEmptySlot, containerFrameItemButtonOnClick-- return the string representation of the given timeLeft constantfunction getTimeLeftString(timeLeft)	local timeLeftString = "";	if timeLeft == Auctioneer.Core.Constants.TimeLeft.Short then		timeLeftString = _AUCT('TimeShort');	elseif timeLeft == Auctioneer.Core.Constants.TimeLeft.Medium then		timeLeftString = _AUCT('TimeMed');	elseif timeLeft == Auctioneer.Core.Constants.TimeLeft.Long then		timeLeftString = _AUCT('TimeLong');	elseif timeLeft == Auctioneer.Core.Constants.TimeLeft.VeryLong then		timeLeftString = _AUCT('TimeVlong');	end	return timeLeftString;endfunction getSecondsLeftString(secondsLeft)	local timeLeft = nil;	for i = table.getn(Auctioneer.Core.Constants.TimeLeft.Seconds), 1, -1 do		if (secondsLeft >= Auctioneer.Core.Constants.TimeLeft.Seconds[i]) then			timeLeft = i;			break		end	end	return getTimeLeftString(timeLeft);endfunction getGSC(money)	local g,s,c = EnhTooltip.GetGSC(money);	return g,s,c;endfunction getTextGSC(money)	return EnhTooltip.GetGSC(money);end-- return an empty string if str is nilfunction nilSafeString(str)	if (not str) then str = "" end	return str;endfunction colorTextWhite(text)	if (not text) then text = ""; end	local COLORING_START = "|cff%s%s|r";	local WHITE_COLOR = "e6e6e6";	return string.format(COLORING_START, WHITE_COLOR, ""..text);endfunction getWarnColor(warn)	--Make "warn" a required parameter and verify that its a string	if (not warn) or (not type(warn) == "String") then		return nil	end	local cHex, cRed, cGreen, cRed;	if (Auctioneer.Command.GetFilter('warn-color')) then		local FrmtWarnAbovemkt, FrmtWarnUndercut, FrmtWarnNocomp, FrmtWarnAbovemkt, FrmtWarnMarkup, FrmtWarnUser, FrmtWarnNodata, FrmtWarnMyprice		FrmtWarnToolow = string.sub(_AUCT('FrmtWarnToolow'), 1, -5);		FrmtWarnNocomp = string.sub(_AUCT('FrmtWarnNocomp'), 1, -5);		FrmtWarnAbovemkt = string.sub(_AUCT('FrmtWarnAbovemkt'), 1, -5);		FrmtWarnUser = string.sub(_AUCT('FrmtWarnUser'), 1, -5);		FrmtWarnNodata = string.sub(_AUCT('FrmtWarnNodata'), 1, -5);		FrmtWarnMyprice = string.sub(_AUCT('FrmtWarnMyprice'), 1, -5);		FrmtWarnUndercut = string.format(_AUCT('FrmtWarnUndercut'), tonumber(Auctioneer.Command.GetFilterVal('pct-underlow')));		FrmtWarnMarkup = string.format(_AUCT('FrmtWarnMarkup'), tonumber(Auctioneer.Command.GetFilterVal('pct-markup')));		if (string.find(warn, FrmtWarnToolow)) then			--Color Red			cHex = "ffff0000";			cRed = 1.0;			cGreen = 0.0;			cBlue = 0.0;		elseif (warn == FrmtWarnUndercut) then			--Color Yellow			cHex = "ffffff00";			cRed = 1.0;			cGreen = 1.0;			cBlue = 0.0;		elseif (string.find(warn, FrmtWarnNocomp) or string.find(warn, FrmtWarnAbovemkt)) then			--Color Green			cHex = "ff00ff00";			cRed = 0.0;			cGreen = 1.0;			cBlue = 0.0;		elseif ((warn == FrmtWarnMarkup) or string.find(warn, FrmtWarnUser) or string.find(warn, FrmtWarnNodata) or string.find(warn, FrmtWarnMyprice)) then			--Color Gray			cHex = "ff999999";			cRed = 0.6;			cGreen = 0.6;			cBlue = 0.6;		end	else		--Color Orange		cHex = "ffe66600";		cRed = 0.9;		cGreen = 0.4;		cBlue = 0.0;	end	return cHex, cRed, cGreen, cBlueend-- Used to convert variables that should be numbers but are nil to 0function nullSafe(val)	if (val == nil) then return 0; end	if (0 + val > 0) then return 0 + val; end	return 0;end-- Returns the current faction's auction signature, depending on locationfunction getAuctionKey()	local serverName = GetCVar("realmName");	local currentZone = GetMinimapZoneText();	local factionGroup;	--Added the ability to record Neutral AH auctions in its own tables.	if ((currentZone == "Gadgetzan") or (currentZone == "Everlook") or (currentZone == "Booty Bay")) then		factionGroup = "Neutral"	else		factionGroup = UnitFactionGroup("player");	end	return serverName.."-"..factionGroup;end-- Returns the current faction's opposing faction's auction signaturefunction getOppositeKey()	local serverName = GetCVar("realmName");	local factionGroup = UnitFactionGroup("player");	if (factionGroup == "Alliance") then factionGroup="Horde"; else factionGroup="Alliance"; end	return serverName.."-"..factionGroup;end-- Returns the current server's neutral auction signaturefunction getNeutralKey()	local serverName = GetCVar("realmName");	return serverName.."-Neutral";end-- Returns the current faction's auction signaturefunction getHomeKey()	local serverName = GetCVar("realmName");	local factionGroup = UnitFactionGroup("player");	return serverName.."-"..factionGroup;end-- function returns true, if the given parameter is a valid option for the also command, false otherwisefunction isValidAlso(also)	if (type(also) ~= "string") then		return false	end	if ((also == 'opposite') or (also == 'off') or (also == 'neutral') or (also == 'home')) then		return true		-- allow special keywords	end	-- check if string matches: "[realm]-[faction]"	local s, e, r, f = string.find(also, "^(.+)-(.+)$")	if (s == nil) then		return false	-- invalid string	end	-- check if faction = "Horde" or "Alliance"	if (f == 'Horde') or (f == 'Alliance')or (f == 'Neutral') then		return true	end	return trueend-- Given an item key, breaks it into its itemID, randomProperty and enchantPropertyfunction breakItemKey(itemKey)	local i,j, itemID, randomProp, enchant = string.find(itemKey, "(%d+):(%d+):(%d+)");	return tonumber(itemID or 0), tonumber(randomProp or 0), tonumber(enchant or 0);endfunction 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 splut;endfunction findClass(cName, sName)	if (AuctionConfig and AuctionConfig.classes) then		for class, cData in pairs(AuctionConfig.classes) do			if (cData.name == cName) then				if (sName == nil) then return class, 0; end				for sClass, sData in pairs(cData) do					if (sClass ~= "name") and (sData == sName) then						return class, sClass;					end				end				return class, 0;			end		end	end	return 0,0;endfunction getCatName(number)	if (number == 0) then return "" end;	if (AuctionConfig.classes[number]) then		return AuctionConfig.classes[number].name;	end	return nil;endfunction getCatNumberByName(name)	if (not name) then return 0 end	if (AuctionConfig and AuctionConfig.classes) then		for cat, class in pairs(AuctionConfig.classes) do			if (name == class.name) then				return cat;			end		end	end	return 0;endfunction getCatForKey(itemKey)	local info = Auctioneer.Core.GetInfo(itemKey);	return info.category;endfunction getKeyFromSig(auctSig)	local id, rprop, enchant = Auctioneer.Core.GetItemSignature(auctSig);	return id..":"..rprop..":"..enchant;endfunction getCatForSig(auctSig)	local itemKey = getKeyFromSig(auctSig);	return getCatForKey(itemKey);endfunction getItemLinks(str)	if (not str) then return nil end	local itemList = {};	local listSize = 0;	for link, item in string.gfind(str, "|Hitem:([^|]+)|h[[]([^]]+)[]]|h") do		listSize = listSize+1;		itemList[listSize] = item.." = "..link;	end	return itemList;endfunction getItems(str)	if (not str) then return nil end	local itemList = {};	local listSize = 0;	local itemKey;	for itemID, randomProp, enchant, uniqID in string.gfind(str, "|Hitem:(%d+):(%d+):(%d+):(%d+)|h") do		itemKey = itemID..":"..randomProp..":"..enchant;		listSize = listSize+1;		itemList[listSize] = itemKey;	end	return itemList;end--Many thanks to the guys at irc://irc.datavertex.com/cosmostesters for their help in creating this functionfunction getItemHyperlinks(str)	if (not str) then return nil end	local itemList = {};	local listSize = 0;	for color, item, name in string.gfind(str, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do		listSize = listSize+1;		itemList[listSize] = "|c"..color.."|Hitem:"..item.."|h["..name.."]|h|r"	end	return itemList;endfunction loadCategories()	if (not AuctionConfig.classes) then AuctionConfig.classes = {} end

⌨️ 快捷键说明

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