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

📄 enxcommand.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
-- Help ME!! (The Handler) (Another shameless copy from the original function)function chatPrintHelp()	Enchantrix.Util.ChatPrint(_ENCH('FrmtUsage'));	local onOffToggle = " (".._ENCH('CmdOn').."|".._ENCH('CmdOff').."|".._ENCH('CmdToggle')..")";	local lineFormat = "  |cffffffff/enchantrix %s "..onOffToggle.."|r |cff2040ff[%s]|r - %s";	Enchantrix.Util.ChatPrint("  |cffffffff/enchantrix "..onOffToggle.."|r |cff2040ff["..Enchantrix.Locale.GetLocalizedFilterVal('all').."]|r - " .. _ENCH('HelpOnoff'));	Enchantrix.Util.ChatPrint("  |cffffffff/enchantrix ".._ENCH('CmdDisable').."|r - " .. _ENCH('HelpDisable'));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('CmdBarker'), Enchantrix.Locale.GetLocalizedFilterVal('barker'), _ENCH('HelpBarker')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('ShowCount'), Enchantrix.Locale.GetLocalizedFilterVal('counts'), _ENCH('HelpCount')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('ShowTerse'), Enchantrix.Locale.GetLocalizedFilterVal('terse'), _ENCH('HelpTerse')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('ShowEmbed'), Enchantrix.Locale.GetLocalizedFilterVal('embed'), _ENCH('HelpEmbed')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('ShowValue'), Enchantrix.Locale.GetLocalizedFilterVal('valuate'), _ENCH('HelpValue')));	if Enchantrix.State.Auctioneer_Loaded then		Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('ShowGuessAuctioneerHsp'), Enchantrix.Locale.GetLocalizedFilterVal('valuate-hsp'), _ENCH('HelpGuessAuctioneerHsp')));		Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('ShowGuessAuctioneerMed'), Enchantrix.Locale.GetLocalizedFilterVal('valuate-median'), _ENCH('HelpGuessAuctioneerMedian')));	else		Enchantrix.Util.ChatPrint(_ENCH('HelpGuessNoauctioneer'));	end	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('ShowGuessBaseline'), Enchantrix.Locale.GetLocalizedFilterVal('valuate-baseline'), _ENCH('HelpGuessBaseline')));	lineFormat = "  |cffffffff/enchantrix %s %s|r - %s";	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('CmdLocale'), _ENCH('OptLocale'), _ENCH('HelpLocale')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('CmdClear'), _ENCH('OptClear'), _ENCH('HelpClear')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('CmdFindBidauct'), _ENCH('OptFindBidauct'), _ENCH('HelpFindBidauct')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('CmdFindBuyauct'), _ENCH('OptFindBuyauct'), _ENCH('HelpFindBuyauct')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('CmdDefault'), _ENCH('OptDefault'), _ENCH('HelpDefault')));	Enchantrix.Util.ChatPrint(string.format(lineFormat, _ENCH('CmdPrintin'), _ENCH('OptPrintin'), _ENCH('HelpPrintin')));end-- The onOff(state, chatprint) function handles the state of the Enchantrix AddOn (whether it is currently on or off)-- If "on" or "off" is specified in the "state" variable then Enchantrix's state is changed to that value,-- If "toggle" is specified then it will toggle Enchantrix's state (if currently on then it will be turned off and vice-versa)-- If no keyword is specified then the function will simply return the current state---- If chatprint is "true" then the state will also be printed to the user.function onOff(state, chatprint)	state = Enchantrix.Locale.DelocalizeFilterVal(state)	if (state == nil) or (state == "") then		state = Enchantrix.Config.GetFilter("all");	elseif (state == 'on') or (state == 'off') then		Enchantrix.Config.SetFilter('all', state);	elseif (state == "toggle") then		Enchantrix.Config.SetFilter('all', not Enchantrix.Config.GetFilter('all'))	end	-- Print the change and alert the GUI if the command came from slash commands. Do nothing if they came from the GUI.	if chatprint then		if Enchantrix.Config.GetFilter('all') then			Enchantrix.Util.ChatPrint(_ENCH('StatOn'));			setKhaosSetKeyParameter('all', "checked", true);		else			Enchantrix.Util.ChatPrint(_ENCH('StatOff'));			setKhaosSetKeyParameter('all', "checked", false);		end	end	return state;end-- The following functions are almost verbatim copies of the original functions but modified in order to make them compatible with direct GUI access.function clear(param, chatprint)	if (param == _ENCH('CmdClearAll')) or (param == "all") then		EnchantedLocal = {}		if (chatprint) then			Enchantrix.Util.ChatPrint(_ENCH('FrmtActClearall'));		end	else		for link in string.gfind(param, "|c%x+|Hitem:%d+:%d+:%d+:%d+|h%b[]|h|r") do			local sig = Enchantrix.Util.GetSigFromLink(link)			EnchantedLocal[sig] = nil			if (chatprint) then				Enchantrix.Util.ChatPrint(string.format(_ENCH('FrmtActClearOk'), link))			end		end	endend-- This function was added by MentalPower to implement the /enx default commandfunction default(param, chatprint)	local paramLocalized	if (param == nil) or (param == "") then		return	elseif (param == _ENCH('CmdClearAll')) or (param == "all") then		param = "all"		EnchantConfig.filters = {}	else		paramLocalized = param		param = Enchantrix.Locale.DelocalizeCommand(param)		Enchantrix.Config.SetFilter(param, nil)	end	if (chatprint) then		if (param == "all") then			Enchantrix.Util.ChatPrint(_ENCH('FrmtActDefaultAll'));			for k,v in pairs(EnchantConfig.filters) do				setKhaosSetKeyValue(k, Enchantrix.Config.GetFilter(k));			end		else			Enchantrix.Util.ChatPrint(string.format(_ENCH('FrmtActDefault'), paramLocalized));			setKhaosSetKeyValue(param, Enchantrix.Config.GetFilter(param));		end	endendfunction genVarSet(variable, param, chatprint)	param = Enchantrix.Locale.DelocalizeFilterVal(param);	if (param == true or param == false) then		Enchantrix.Config.SetFilter(variable, param);	elseif (param == 'toggle' or param == nil or param == "") then		Enchantrix.Config.SetFilter(variable, not Enchantrix.Config.GetFilter(variable))	end	if (chatprint) then		if (Enchantrix.Config.GetFilter(variable)) then			Enchantrix.Util.ChatPrint(string.format(_ENCH('FrmtActEnable'), Enchantrix.Locale.LocalizeCommand(variable)));			setKhaosSetKeyParameter(variable, "checked", true);		else			Enchantrix.Util.ChatPrint(string.format(_ENCH('FrmtActDisable'), Enchantrix.Locale.LocalizeCommand(variable)));			setKhaosSetKeyParameter(variable, "checked", false);		end	endend-----------------------------------------   Auctioneer dependant commands   -----------------------------------------function percentLessFilter(percentLess, signature)	local filterAuction = true;	local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature);	local disenchantsTo = getAuctionItemDisenchants(signature, true);	if not disenchantsTo.totals then return filterAuction; end	local hspValue = disenchantsTo.totals.hspValue or 0;	local medValue = disenchantsTo.totals.medValue or 0;	local mktValue = disenchantsTo.totals.mktValue or 0;	local confidence = disenchantsTo.totals.conf or 0;	local myValue = confidence * (hspValue + medValue + mktValue) / 3;	local margin = Auctioneer.Statistic.PercentLessThan(myValue, buyout/count);	local profit = (myValue * count) - buyout;	local results = {		buyout = buyout,		count = count,		value = myValue,		margin = margin,		profit = profit,		conf = confidence	};	if (buyout > 0) and (margin >= tonumber(percentLess)) and (profit >= MIN_PROFIT_MARGIN) then		filterAuction = false;		profitMargins[signature] = results;	end	return filterAuction;endfunction bidBrokerFilter(minProfit, signature)	local filterAuction = true;	local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature);	local currentBid = Auctioneer.Statistic.GetCurrentBid(signature);	local disenchantsTo = getAuctionItemDisenchants(signature, true);	if not disenchantsTo.totals then return filterAuction; end	local hspValue = disenchantsTo.totals.hspValue or 0;	local medValue = disenchantsTo.totals.medValue or 0;	local mktValue = disenchantsTo.totals.mktValue or 0;	local confidence = disenchantsTo.totals.conf or 0;	local myValue = confidence * (hspValue + medValue + mktValue) / 3;	local margin = Auctioneer.Statistic.PercentLessThan(myValue, currentBid/count);	local profit = (myValue * count) - currentBid;	local profitPricePercent = math.floor((profit / currentBid) * 100);	local results = {		buyout = buyout,		count = count,		value = myValue,		margin = margin,		profit = profit,		conf = confidence	};	if (currentBid <= MAX_BUYOUT_PRICE) and (profit >= tonumber(minProfit)) and (profit >= MIN_PROFIT_MARGIN) and (profitPricePercent >= MIN_PROFIT_PRICE_PERCENT) then		filterAuction = false;		profitMargins[signature] = results;	end	return filterAuction;endfunction profitComparisonSort(a, b)	if (not a) or (not b) then return false; end	local aSig = a.signature;	local bSig = b.signature;	if (not aSig) or (not bSig) then return false; end	local aEpm = profitMargins[aSig];	local bEpm = profitMargins[bSig];	if (not aEpm) and (not bEpm) then return false; end	local aProfit = aEpm.profit or 0;	local bProfit = bEpm.profit or 0;	local aMargin = aEpm.margin or 0;	local bMargin = bEpm.margin or 0;	local aValue  = aEpm.value or 0;	local bValue  = bEpm.value or 0;	if (aProfit > bProfit) then return true; end	if (aProfit < bProfit) then return false; end	if (aMargin > bMargin) then return true; end	if (aMargin < bMargin) then return false; end	if (aValue > bValue) then return true; end	if (aValue < bValue) then return false; end	return false;endfunction bidBrokerSort(a, b)	if (not a) or (not b) then return false; end	local aTime = a.timeLeft or 0;	local bTime = b.timeLeft or 0;	if (aTime > bTime) then return true; end	if (aTime < bTime) then return false; end	return profitComparisonSort(a, b);endfunction doPercentLess(percentLess)	if not Auctioneer then		Enchantrix.Util.ChatPrint("You do not have Auctioneer installed. Auctioneer must be installed to do an enchanting percentless scan");		return;	elseif not (Auctioneer.Filter and Auctioneer.Filter.QuerySnapshot) then		Enchantrix.Util.ChatPrint("You do not have the correct version of Auctioneer installed, this feature requires Auctioneer v3.3.0.0675 or later");		return;	end	if not percentLess or percentLess == "" then percentLess = MIN_PERCENT_LESS_THAN_HSP end	local output = string.format(_ENCH('FrmtPctlessHeader'), percentLess);	Enchantrix.Util.ChatPrint(output);	Enchantrix.Storage.Price_Cache = {t=time()};	profitMargins = {};	local targetAuctions = Auctioneer.Filter.QuerySnapshot(percentLessFilter, percentLess);	-- sort by profit based on median	table.sort(targetAuctions, profitComparisonSort);	-- output the list of auctions	for _,a in targetAuctions do		if (a.signature and profitMargins[a.signature]) then			local quality = EnhTooltip.QualityFromLink(a.itemLink);			if (quality and quality >= 2) then				local id,rprop,enchant, name, count,_,buyout,_ = Auctioneer.Core.GetItemSignature(a.signature);				local value = profitMargins[a.signature].value;				local margin = profitMargins[a.signature].margin;				local profit = profitMargins[a.signature].profit;				local output = string.format(_ENCH('FrmtPctlessLine'), Auctioneer.Util.ColorTextWhite(count.."x")..a.itemLink, EnhTooltip.GetTextGSC(value * count), EnhTooltip.GetTextGSC(buyout), EnhTooltip.GetTextGSC(profit * count), Auctioneer.Util.ColorTextWhite(margin.."%"));				Enchantrix.Util.ChatPrint(output);			end		end	end	Enchantrix.Util.ChatPrint(_ENCH('FrmtPctlessDone'));endfunction doBidBroker(minProfit)	if not Auctioneer then		Enchantrix.Util.ChatPrint("You do not have Auctioneer installed. Auctioneer must be installed to do an enchanting percentless scan");		return;	elseif not (Auctioneer.Filter and Auctioneer.Filter.QuerySnapshot) then		Enchantrix.Util.ChatPrint("You do not have the correct version of Auctioneer installed, this feature requires Auctioneer v3.3.0.0675 or later");		return;	end	if not minProfit or minProfit == "" then minProfit = MIN_PROFIT_MARGIN; else minProfit = tonumber(minProfit) * 100; end	local output = string.format(_ENCH('FrmtBidbrokerHeader'), EnhTooltip.GetTextGSC(minProfit));	Enchantrix.Util.ChatPrint(output);	Enchantrix.Storage.Price_Cache = {t=time()};	profitMargins = {};	local targetAuctions = Auctioneer.Filter.QuerySnapshot(bidBrokerFilter, minProfit);	-- sort by profit based on median	table.sort(targetAuctions, bidBrokerSort);	-- output the list of auctions	for _,a in targetAuctions do		if (a.signature and profitMargins[a.signature]) then			local quality = EnhTooltip.QualityFromLink(a.itemLink);			if (quality and quality >= 2) then				local id,rprop,enchant, name, count, min, buyout,_ = Auctioneer.Core.GetItemSignature(a.signature);				local currentBid = Auctioneer.Statistic.GetCurrentBid(a.signature);				local value = profitMargins[a.signature].value;				local margin = profitMargins[a.signature].margin;				local profit = profitMargins[a.signature].profit;				local bidText = _ENCH('FrmtBidbrokerCurbid');				if (currentBid == min) then					bidText = _ENCH('FrmtBidbrokerMinbid');				end				local output = string.format(_ENCH('FrmtBidbrokerLine'), Auctioneer.Util.ColorTextWhite(count.."x")..a.itemLink, EnhTooltip.GetTextGSC(value * count), bidText, EnhTooltip.GetTextGSC(currentBid), EnhTooltip.GetTextGSC(profit * count), Auctioneer.Util.ColorTextWhite(margin.."%"), Auctioneer.Util.ColorTextWhite(Auctioneer.Util.GetTimeLeftString(a.timeLeft)));				Enchantrix.Util.ChatPrint(output);			end		end	end	Enchantrix.Util.ChatPrint(_ENCH('FrmtBidbrokerDone'));endfunction getAuctionItemDisenchants(auctionSignature, useCache)	local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(auctionSignature);	local sig = string.format("%d:%d:%d", id, enchant, rprop);	return Enchantrix.Storage.GetItemDisenchants(sig, name, useCache);endEnchantrix.Command = {	Revision				= "$Revision: 900 $",	AddonLoaded				= addonLoaded,	AuctioneerLoaded		= auctioneerLoaded,	HandleCommand			= handleCommand,	Register				= register,	--ResetKhaos				= resetKhaos,	SetKhaosSetKeyValue		= setKhaosSetKeyValue,	SetKhaosSetKeyParameter	= setKhaosSetKeyParameter,	SetKhaosSetKeyValue		= setKhaosSetKeyValue,}

⌨️ 快捷键说明

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