KlazScipts/Modules/Automation/Repair.lua

34 lines
1.2 KiB
Lua
Raw Normal View History

2024-03-17 22:33:11 +00:00
local addon, ns = ...
local L = ns.L
--------------------------------------------------------------------------------
-- # MODULES > AUTOMATION > REPAIR
--------------------------------------------------------------------------------
local autoRepair = true
local autoRepairGuild = true
local f = CreateFrame('Frame')
f:RegisterEvent('MERCHANT_SHOW')
f:SetScript('OnEvent', function()
if CanMerchantRepair() then
local cost = GetRepairAllCost()
if cost > 0 then
-- using guild funds
if autoRepairGuild == true and GetGuildBankWithdrawMoney() >= cost then
RepairAllItems(1)
print('Klaz|cff1994ffScripts|r — |cnYELLOW_FONT_COLOR:'..L.AUTO_REPAIR_GUILD..':|r '..GetCoinTextureString(cost, 10)) -- print using currency icons
PlaySound(SOUNDKIT.ITEM_REPAIR)
-- using personal funds
elseif autoRepair == true and GetMoney() > cost then
RepairAllItems()
print('Klaz|cff1994ffScripts|r — |cnYELLOW_FONT_COLOR:'..L.AUTO_REPAIR..':|r '..GetCoinTextureString(cost, 10)) -- print using currency icons
PlaySound(SOUNDKIT.ITEM_REPAIR)
-- no money
else
print('Klaz|cff1994ffScripts|r — |cnRED_FONT_COLOR:'..L.AUTO_REPAIR_BROKE..'.|r')
end
end
end
end)