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

📄 autorepair.lua

📁 时间太紧了
💻 LUA
字号:
-- ============================================= --
--                  www.17cube.com               --
-- ============================================= --


function AutoRepair_OnLoad()
	this:RegisterEvent("MERCHANT_SHOW");
	this:RegisterEvent("VARIABLES_LOADED");
	SlashCmdList["RepairCost"] = function()
		Cost_SlashCommand();
	end
	SLASH_RepairCost1 = "/autorepair";
	SLASH_RepairCost2 = "/ar";
end

function Repair_Register()

  gLim_RegisterButton (
	"Auto Repair",
	"自动修理",
	"Interface\\AddOns\\AutoRepair\\Icon",
	function()
		gLimModSecBookShowConfig("gLimAutoRepair");
	end,
	3,
	8
	);
	gLim_RegisterConfigClass("gLimAutoRepair","Auto Repair","CraZy aPpLe");
	gLim_RegisterConfigSection("gLimAutoRepairSection",AUTOREPAIR_WINDOW_CONFIG_TEXT,AUTOREPAIR_WINDOW_CONFIG_TEXT.." by CraZy aPpLe(gLim开发小组)",AUTOREPAIR_WINDOW_CONFIG_TEXT,"gLimAutoRepair");
	gLim_RegisterConfigCheckBox(
	"gLim_Repair_Enable",
	REPAIR_WINDOW_DISPLAY,
	REPAIR_WINDOW_DISPLAY_INFO,
	OnOff_AutoRepair,
	OnOffRepair,
	"gLimAutoRepair"
	);	
end

function OnOffRepair(toggle)
		OnOff_AutoRepair = toggle;
end


function AutoRepair_OnEvent(event)
	if (event == "VARIABLES_LOADED") then
		if ( not OnOff_AutoRepair ) then
			OnOff_AutoRepair = 0;
		end
		if (not Repair_Cost) then
		Repair_Cost = 0;
		end
		Repair_Register();
	end
	if (event == "MERCHANT_SHOW" and OnOff_AutoRepair == 1) then
		if ( CanMerchantRepair() ) then			
			if (GetRepairAllCost() == 0) then
				local name, description, textureIndex, x, y = GetMapLandmarkInfo( 2 );
			else
				if ( GetRepairAllCost() < GetMoney() ) then				
					RepairAllItems();
					Repair_Cost = Repair_Cost+GetRepairAllCost();
					local GC = nil;
					local SC = nil;
					local CC = nil;
					GC,SC,CC = Cost_Change(GetRepairAllCost());
					if (GC == 0) then
						GC = "";
					else
						GC = format(GC.."金币");
					end
					if (SC == 0) then
						SC = "";
					else
						SC = format(SC.."银币");
					end
					if (CC == 0) then
						CC = "";
					else
						CC = format(CC.."铜币");
					end
					MFC.IO.print("自动修理了所有装备,此次修理装备花费:"..GC..SC..CC..".");
					GC,SC,CC = Cost_Change(Repair_Cost);
					if (GC == 0) then
						GC = "";
					else
						GC = format(GC.."金币");
					end
					if (SC == 0) then
						SC = "";
					else
						SC = format(SC.."银币");
					end
					if (CC == 0) then
						CC = "";
					else
						CC = format(CC.."铜币");
					end
					--MFC.IO.print("您修理装备总共花费了"..GC..SC..CC);
				else
					MFC.IO.print("抱歉,你的钱不够修复全身装备.");
				end
			end
		end
	end
end

function Cost_Change(Cost)
	local Cost_Gold = floor(Cost/10000);
	Cost = Cost - Cost_Gold*10000;
	local Cost_Silver = floor(Cost/100);
	Cost = Cost - Cost_Silver*100;
	local Cost_Copper = Cost;
	return Cost_Gold,Cost_Silver,Cost_Copper;	
end

function Cost_SlashCommand()
	GC,SC,CC = Cost_Change(Repair_Cost);
		if (GC == 0) then
			GC = "";
		else
			GC = format(GC.."金币");
		end
		if (SC == 0) then
			SC = "";
		else
			SC = format(SC.."银币");
		end
		if (CC == 0) then
			CC = "";
		else
			CC = format(CC.."铜币");
		end
		if (GC == "" and SC == "" and CC == "") then
			MFC.IO.print("你还没有修理过任何装备.");
		else
			MFC.IO.print("你修理装备总共花费了:"..GC..SC..CC..".");	
		end
		
end

⌨️ 快捷键说明

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