The functions had errors in them I had to debug so I'm reposting this from the start:
RepairByItem(<Item Type>, <Item Count>);
RepairByDura(<Equip Slot>, <Equip Dura>);
RepairByFullBag();
Add the following to the end of player.lua:
Code: Select all
-- load repair path based on item counts (healing, mana, arrow, thrown, poison)
function CPlayer:RepairByItem(_ItemType, _ItemCount)
inventory:update();
if (_ItemType == "poison") then
if ( _ItemCount > (inventory:itemTotalCount( "Poison" ))) then
local _RepairPath = string.gsub( __WPL:getFileName(),".xml", "_repair.xml" );
loadPaths(_RepairPath);
end
else
if( _ItemCount > ( inventory:itemTotalCount( inventory:bestAvailableConsumable(_ItemType) ) ) ) then
local _RepairPath = string.gsub( __WPL:getFileName(),".xml", "_repair.xml" );
loadPaths(_RepairPath);
end
end
end
-- load repair path based on Durability of an item (Helmet, Gloves, Feet, Chest, Legs, Back, Waist, Shoulder, Necklace, Ammo, Ranged, Ring1, Ring2, Earring1, Earring2, MainHand, OffHand, Shield)
function CPlayer:RepairByDura(_EquipSlot, _ItemDura)
slotID = {};
slotID["Helmet"] = 0;
slotID["Gloves"] = 1;
slotID["Feet"] = 2;
slotID["Chest"] = 3;
slotID["Legs"] = 4;
slotID["Back"] = 5;
slotID["Waist"] = 6;
slotID["Shoulder"] = 7;
slotID["Necklace"] = 8;
slotID["Ammo"] = 9;
slotID["Ranged"] = 10;
slotID["Ring1"] = 11;
slotID["Ring2"] = 12;
slotID["Earring1"] = 13;
slotID["Earring2"] = 14;
slotID["MainHand"] = 15;
slotID["OffHand"] = 16;
slotID["Shield"] = 16;
local equipslot = slotID[_EquipSlot]
local equipdura = inventory:getDurability(equipslot);
if( _ItemDura > equipdura ) then
local _RepairPath = string.gsub( __WPL:getFileName(),".xml", "_repair.xml" );
loadPaths(_RepairPath);
end
end
-- load repair path based on bags being full
function CPlayer:RepairByFullBag()
occupiedSlots, totalSlots = sendMacro("GetBagCount();");
availableSlots = (totalSlots - occupiedSlots)
if availableSlots == 0 then
local _RepairPath = string.gsub( __WPL:getFileName(),".xml", "_repair.xml" );
loadPaths(_RepairPath);
end
end
player:RepairByFullBag();
player:RepairByItem("healing", 99);
player:RepairByDura("MainHand", 80);
Please let me know if you find any more bugs in this or if you have improvements to add. Thank you and please...
Enjoy!