View Feature Request
Auto Repair Equipped Cost Check
Feature #: 251
File: XAutoRepair
Date: 05/01/14 02:18 PM
By: Tamha
Status: Under Review
I've already implemented this code into my own copy of XAutoRepair, but I thought perhaps your other users might like it as well. This takes your code to determine the repair cost for equipped items and runs it on the Shop Open event to see if you can afford to repair all equipped items if you do not have enough money on hand to repair all damaged items. (I also fixed all instances of "equiped" to "equipped" in my own copy of the mod.)

Lua Code:
  1. function XAR.OnShopOpen()
  2.     local cost = GetRepairAllCost()
  3.     local costEquipped = 0;
  4.     if GetCurrentMoney() >= cost then
  5.         if XAR.Saved.onlyEquipped then
  6.             XAR.RepairOnlyEquippedItems()
  7.         else
  8.             XAR.RepairAllItems()
  9.         end
  10.     elseif XAR.Saved.onlyEquipped then
  11.         local _, bagSlots = GetBagInfo(BAG_WORN)
  12.         for slotIndex=0, bagSlots - 1 do
  13.             local condition = GetItemCondition(bagId, slotIndex)
  14.             if condition < 100 then
  15.                 local icon, stackCount, _, _, _, _, _, quality = GetItemInfo(bagId, slotIndex)
  16.                 if stackCount > 0 then
  17.                     local repairCost = GetItemRepairCost(bagId, slotIndex)
  18.                     if repairCost > 0 then
  19.                         costEquipped = costEquipped + repairCost;
  20.                     end
  21.                 end
  22.             end
  23.         end
  24.         if GetCurrentMoney() >= costEquipped then
  25.             XAR.RepairOnlyEquippedItems()
  26.         else
  27.             XAR.print("Not enough gold")
  28.         end
  29.     else
  30.         XAR.print("Not enough gold")
  31.     end
  32. end

Additionally, is there any chance that we can get an adjustable condition check implemented? I manually altered my code to only repair at "condition <= 75" for my own game, but perhaps a slider or even a checkbox that changes the condition check from 100 to 76 could be added? Items with a condition of 76-99 supposedly do not suffer from degradation debuffing, so they don't necessarily require repair.